Commits, staging and stashes in ddugit

Everything between editing a file and having a commit: choosing what goes in, down to single lines, writing the message, fixing the last commit, and putting work aside in a stash. It also covers who your commits are made as and how they are signed.

Updated

Open the commit panel

When files change on disk, ddugit picks it up on its own. There are three ways to open the commit panel:

The panel opens on the right and lists every changed file. A letter shows what happened to each one: M modified, A added, U untracked (new), D deleted, R renamed, and ! for a file with conflicts. A ½ mark means the file is partially staged: some of its changes are staged and some are not. Click a file's path to open its diff in the Changes sheet under the graph. A file with conflicts opens in the conflict sheet instead.

Two ways to choose what goes in

Pick files (the default)

Every changed file starts ticked. Untick the ones that should wait. When you commit, ddugit adds and commits exactly the ticked files, whatever is or isn't staged. You never have to think about the index. The header counts how many files are selected.

Commit staged changes only

Tick Commit staged changes only to commit the index as it is, the way git commit does. In this mode a file's checkbox stages and unstages it, and the checkbox in the header is Stage all or Unstage all. The header counts staged files instead.

You rarely have to switch by hand. The panel starts in this mode when a file is already partially staged. It also switches as soon as you stage something yourself, whether from the diff sheet, a file's menu or a terminal. That way a hunk you staged carefully is never committed together with the rest of its file.

Stage files, hunks and single lines

The Changes sheet for the working tree has two tabs, Unstaged and Staged. A file that is fully staged opens on the Staged tab.

On the Staged tab the same buttons unstage: Unstage file, Unstage all, Unstage this hunk and Unstage 2 selected lines. Press [ and ] to move to the previous or next file, and Esc to close the sheet. A file that still has conflicts can't be staged until you resolve it, because staging it would mark it resolved with the conflict markers still inside.

Right-clicking a file in the commit panel also gives you Stage and Unstage for the whole file.

Discard changes

To throw away the changes in whole files, select them in the commit panel and click Discard selected. A confirmation lists the files first. They go back to how they were in the last commit, and new files are deleted. This can't be undone, because the changes were never committed.

To throw away part of a file, use the Unstaged tab of the diff sheet. Each hunk has Discard hunk, or Discard 2 selected lines once you have selected lines. Only the working tree changes. Whatever you already staged stays.

Ignore files and stop tracking them

Right-click a file in the commit panel. For a new, untracked file you can add a pattern to .gitignore:

ddugit appends the pattern to the .gitignore at the top of the repository and skips patterns that are already there. Characters that mean something special in a pattern are escaped.

A file Git already tracks needs to come out of the repository first. Stop tracking (keep file) removes it from Git but leaves it on your disk (git rm --cached). Stop tracking and ignore also adds it to .gitignore. Both ask first. Once you commit and push, other people lose their copy of the file when they pull. Either way, commit the changed .gitignore and the removal like any other change.

Write the message and commit

Type the message in the box. The first line is the summary. Click Commit or press ⌘/Ctrl + Enter. To start a branch for this work at the same time, tick Commit on a new branch and type its name. ddugit creates the branch, switches to it and commits there.

If the repository sets commit.template, an empty message starts with the template's text, minus its # comment lines. Committing the template unchanged is refused with This is still the commit template. Fill it in first, just as Git refuses it.

Commit options

When a hook rejects the commit

Hooks run as usual. If one fails, nothing is committed and the error notification shows Git's output, including what the hook printed. You can select and copy that text. Fix the problem and commit again, or tick Skip hooks if you really mean to commit past it.

Amend the last commit

Tick Amend last commit in the commit panel. If the message box is empty, the last commit's message fills it so you can edit it, and the button becomes Amend commit. The selected files are added to that commit. With no files selected, only the message changes.

You can also right-click the HEAD commit on the map and choose Amend last commit. The panel then opens in amend mode with nothing selected, ready for a new message. If the commit is already on the remote, the panel warns you: amending it means you will need to force push.

To take the last commit back entirely, see undoing in ddugit.

Who you commit as

The top of the commit panel shows the name and email your next commit will use. Next to it, a tag says where that identity comes from: local means this repository sets its own (git config --local), and global means your global Git settings. A Signed tag means the commit will be signed. If no name or email is set anywhere, the panel warns you that commits will fail.

Click the name to open Commit in this repository as:

Profiles

Profiles live in Settings → Profiles. Use them when you commit as different people in different places, for example a work email for company repositories and a personal one for your own projects. The page shows your global identity and, when a signing key is set, a Sign commits in every repository (global) switch. If you have no profiles yet, ddugit offers to create one from your global identity.

Click + Add profile and fill in Name, Email and Signing: Don't sign, GPG or SSH. For signing, the Signing key field suggests the keys found on this computer: GPG secret keys from gpg, or SSH public keys in ~/.ssh. Use globally makes a profile your global Git identity.

Signing commits

ddugit runs Git without a terminal, so it can't ask for a key's passphrase. A GPG key with a passphrase needs a graphical pinentry (pinentry-mac on macOS, Gpg4win on Windows) or a gpg-agent that already holds it. Add an SSH key with a passphrase to ssh-agent first (ssh-add). When signing fails, the error says which of these to check.

Signed commits get a badge in the inspector when you select them: Signed, Signed (unverified) or Bad signature. Hover over it to see who signed and with which key, or a note that this computer can't verify the signing key.

Stash work for later

A stash puts changes aside and gives you a clean working tree, for example to switch branches or pull. In the commit panel, choose the files and click Stash. In staged-only mode it stashes the staged files. The Stash changes window asks for:

⌘/Ctrl + Shift + S stashes all changes at once, untracked files included, without asking.

Find and restore a stash

Stashes are listed in the sidebar under Stashes. On the map, each one is a small diamond hanging off the commit it was taken on. Click either to open the stash panel. It shows when you stashed, the base commit and the changed files. Untracked files aren't listed there, but they are in the stash if you included them. Then choose:

Right-click a stash in the sidebar for the same actions.

For branches, merges and syncing with remotes, see Branches, merges and remotes.

On the command line

Roughly what ddugit runs for you:

git add -A -- <files> && git commit -m "message" -- <files>   # pick files
git commit -m "message"                                         # staged changes only
git add -p                                                      # hunks and lines
git commit --amend
git commit --no-verify -s -m "message"
git rm --cached <file> && echo "/<file>" >> .gitignore
git stash push --include-untracked -m "message"
git stash pop        # or: git stash apply, git stash branch <name>, git stash drop