Inspect, compare and rewrite history in ddugit

Everything that looks back: what a commit changed, how two points in history differ, who wrote a line, and the tools that change past commits or take you back to where you were.

Updated

Most of this chapter starts from one place: a commit on the branch map. Click it to read it, right-click it to act on it. Entries that don't apply to that commit stay in the menu but are greyed out, so you can always see what exists.

The inspector

Click a commit and the inspector opens on the right. From the top, it shows:

ddugit with a commit selected on the branch map and the inspector on the right showing its message, author, parent, branches and changed files
The inspector for “Tune particle speed”: message, author, IDs, branches, actions and changed files.

The diff sheet

Click a file under Changed files to open the diff sheet under the graph: the commit's files on the left, the selected file's unified diff on the right. Press ] and [ for the next and previous file and Esc to close. Drag the sheet's top edge to make it taller. Binary files and files that only changed mode or name say so instead of showing lines, and files stored in Git LFS show the pointer's size and object ID before and after.

The same sheet shows your uncommitted changes, where you can also stage single hunks and lines: see Commits, staging and stashes.

Compare two revisions

Comparing opens the diff sheet with the title Compare and the two sides in its header.

In the sheet, switch between Since they split (changes on the second side since the merge base) and Tip to tip (the plain difference between the two snapshots). Swap sides reverses the direction. Renamed files are shown as renames.

File history, blame and old versions

Right-click a file in the inspector's changed files for everything about that one file.

File history

Show this file's history lists every commit that changed the file, following it through renames. A banner says how many commits changed it. Newer and Older step through them on the map, Blame opens the blame sheet at the selected commit, and Close ends it.

Blame

Show who last changed each line (blame) opens the file as of that commit, in blocks of lines with the commit, author and date of their last change. Blue is newer, red is older. Click a block's left margin to go to its commit on the map.

Open, save or restore a version

Cherry-pick and revert

To copy a commit onto another branch, hold Alt (⌥ on a Mac) and drag it onto that branch's tip, or right-click it and choose Cherry-pick onto <your branch>…. The dialog says what will be copied, and if the target isn't checked out, that ddugit checks it out first. The original commit ID is recorded in the new commit's message.

To pick several, ⌘/Ctrl-click commits on the map (Shift-click picks a line of them), then right-click one of them:

Revert commit… undoes one commit on your branch with a new commit. For a merge commit the entry reads Revert merge commit…, and the dialog asks Which side should stay?: pick Parent 1 (usually the branch you merged into) or Parent 2. Each option shows the parent's ID, message and branches.

If a pick or revert stops on conflicts, a banner offers Resolve conflicts, Continue, Skip and Cancel. The step-by-step version, and the backport sheet for many fixes at once, are in the cherry-pick and backport guide.

Rearrange and edit past commits

Rearrange commits after this… (rebase -i) on a commit's menu opens a list of the commits after it to reorder, squash, fix up or drop. Shift-dragging a commit onto another opens the same list with that move made. See the interactive rebase guide.

To change one older commit without the full list, right-click it:

Each dialog says how many commits will be rewritten (this one and every commit after it on your branch) and warns when any of them were already pushed, since pushing again will then need a force push. Your uncommitted changes are set aside and put back. The entries are available for commits on your current branch that aren't merges and have no merge commit after them.

Rewriting runs your Git hooks. If a hook such as pre-commit rejects a commit, ddugit cancels the whole rewrite, leaves your branch and files as they were, and shows what the hook printed.

Reset and the undo history

Undo last commit (keep changes) takes the newest commit off your branch and stages its changes. Reset to here… moves your branch to the commit you right-clicked and asks what happens to the changes of the commits that leave it:

A remote branch's menu has Reset <your branch> to here… too, for going back to origin/main after your branch went its own way.

The clock button in the top bar, Undo history (reflog), lists every commit HEAD has pointed to: commits, resets, checkouts, merges, rebases, pulls and more. Commits no branch reaches any more are marked Lost. Choose Recover as branch to put a branch on one, or Reset to here… to go back to it. The undo, reset and reflog guide walks through each case.

Find the commit that broke something (bisect)

Bisect finds the first bad commit by halving the range until one is left. You need one commit that has the bug and an older one that doesn't.

  1. Right-click a commit with the bug and choose Mark as bad (has the bug). A banner asks for the other end.
  2. Right-click an older commit without it and choose Mark as good (no bug). The good commit has to be an ancestor of the bad one. Bisect starts.
  3. ddugit checks out a commit in the middle and centres the map on it. Commits that can't be the culprit fade back. The banner says how many candidates and roughly how many steps are left.
  4. Build or test that commit, then click Good, Bad, or Skip when it can't be tested.
  5. When one commit is left, the banner shows First bad commit. Show takes you to it.
  6. Click Finish to end bisect and go back to your branch.

Patches

A patch carries one commit as a text file, for a repository you can't push to or a mailing list. On a commit's menu:

A merge commit has no single patch, so both are unavailable for merges.

To apply one, open the branch switcher on the left of the top bar and choose Apply patch…, then pick the file. It goes onto your current branch:

git format-patch -1 --stdout 7e44b09 > fix.patch   # save a commit as a patch
git am --3way fix.patch                            # apply a mailed patch as commits
git apply --3way change.diff                       # apply a plain diff to the working tree

External diff and merge tools

If you prefer a separate program for reading diffs or merging, ddugit hands off to it:

These run git difftool and git mergetool. Choose the tools in Settings under External apps, or keep As set in git: see Settings and keyboard shortcuts.