Git and pull requests

Review and undo what DCode changed, commit and push it, give a task its own worktree, and open a pull request and fix its failing checks.

On this page

DCode works in your git repository like you do: it reads the history, changes files in the working tree and leaves the commits to you unless you ask. Everything on this page works in any git project; pull requests need a GitHub remote.

See what DCode changed

In the desktop app, each turn that changed files ends with a list of them. Review shows a file's diff and Open in editor opens it. Under Git tools in the conversation's panel, Changes shows the project's changes, by source, with a diff for each file:

  • Unstaged and Staged: your working tree, with Stage, Unstage and Discard for each file.
  • All branch changes: everything on the branch.
  • Last turn: only what DCode's last turn changed.

In the CLI, /diff lists the files DCode changed in this session and shows their diffs, and /diff --git adds the git diff of the working tree.

Have DCode review the changes

In the CLI, /review looks at your staged, unstaged and new files for bugs, risks and missing tests. /review <branch> reviews this branch against another since they split, and /review --staged the staged changes only. /security-review takes the same targets and looks for injection, mistakes in authentication, secrets in code, unsafe input handling, weak cryptography, risky new dependencies and permissions that are too broad, each with its severity, file and line and a fix. Both only report: ask for the fixes afterwards. A custom command of your own named /review or /security-review takes its place.

Undo DCode's changes

In the desktop app, Undo in a turn's list of changed files puts those files back. DCode first checks each file again: the dialog shows which files are safe to undo and which are not, for example a file that changed outside the turn. If another program changed a file in the meantime, no file is written. Changes made by shell commands are not undone this way. Reapply puts the turn's changes back.

In the CLI, /rewind opens a list of the project's checkpoints and restores the one you pick; /rewind latest goes straight to the latest, and /rewind status shows it. /fork starts a new session from a checkpoint, leaving the current one as it is. In the app, Fork on a message does the same once the task has finished.

Commit and push

In the desktop app, open Commit / Push under Git tools:

  1. Choose Commit. The dialog shows the branch and how many files change.
  2. Write the message, or choose Generate message to have DCode write it; left empty, DCode writes one when you commit. Tick Include unstaged changes to commit those too.
  3. Choose Commit, or Commit and push.

Push shows the remote branch and how far ahead and behind it you are before it pushes. The branch control switches branches, searches them, and Create and switch to new branch makes a new one. Git needs your name and email to commit; the dialog says so if they are missing.

In the CLI, ask in your own words: DCode commits and pushes with git like any other command, under your permission mode. In Auto, a push always waits for your yes, and so do force pushes, history rewrites and deleting branches (Permission modes).

Give a task its own worktree

A worktree is a separate copy of the project on a new branch, so a task can work without clashing with your own edits or with other tasks.

In the desktop app

  1. On a new task, open Worktree and choose Run in its own worktree.
  2. Give it a short name, such as fix-login. The dialog shows the new branch, on dcode/.
  3. Choose Create worktree, then send your task. It runs there, and its chip says which branch.

The worktree starts from your last commit and is made outside your project folder. Changes you have not committed stay in the main folder, and dependencies are not copied: folders such as node_modules, virtual environments and build output are not there, so install them in the worktree if the task has to run or test the code. The project needs at least one commit.

  • Bring back saves any uncommitted changes in the worktree as a commit on its branch, then merges that branch into the branch your main folder is on. If your main folder has uncommitted changes, is not on a branch, or the two branches change the same lines, DCode changes nothing and gives you the commands to run instead.
  • Manage worktrees lists the project's worktrees with their uncommitted changes, and offers Open, Bring back, Clean up and Copy commands.
  • Clean up removes the worktree and its branch. A branch with commits that are not merged is kept.

In the CLI

shell
# start a session in a new worktree on the branch dcode/fix-logindcode --worktree fix-login# list them, and remove onedcode worktree listdcode worktree remove fix-login

Without a name, the date and time are the name. When the session ends, DCode prints how to merge the branch back and how to remove the worktree. --worktree also works with -p and --target, but not with --resume or --continue. dcode worktree remove --force removes a worktree that has uncommitted changes, and those changes are lost.

Pull requests

The desktop app opens pull requests on GitHub with the GitHub CLI, gh. If it is missing or not signed in, Set up pull requests shows what to run; choose Check again when it is done. The project needs a GitHub remote.

  1. On a branch with your commits, choose Create pull request under Git tools.
  2. DCode reads your commits and fills in the title and description; edit them, and pick the base branch.
  3. Choose Create pull request. If the branch is not on GitHub yet, the button reads Push and create and pushes it first.

The row then shows the pull request's number, its state (Open, Draft, Merged or Closed) and its checks. Open it to see each check, Open on GitHub or Refresh checks; while the panel is open, the checks refresh every minute.

Fix failing checks

When a check fails, choose Fix failing checks, then Start task. DCode opens a new task in the project whose prompt lists the failing checks and the end of their logs, and asks the agent to find the cause, change the code and run the same checks locally where it can. Press Send to start it.