Undo
The "don't commit" list
4 min read
Every project has that file you change and shouldn't commit: a configuration pointing to your local
database, a launchSettings.json with your port, a half-finished test script. It's already tracked
by git (that's why .gitignore doesn't help), and a hurried "stage all" takes it along into the
commit.
The "don't commit" list solves that. A marked file:
- goes into a group of its own in the changes panel, Don't commit (N);
- is left out of Stage all changes, in all its forms;
- if it gets staged anyway, the commit asks before taking it.
The list is yours alone: it stays on your computer, per worktree, and never goes into the repository or to the remote.
- The file's menu (right-click a file in the changes panel, staged or unstaged): Don't commit this file. On a file that is on the list, the item becomes Remove from the "don't commit" list.
- The Don't commit group in the changes panel: each file's button, Remove from the "don't commit" list (back to Unstaged).
- Preferences › Commit message › "Don't commit" list of meu-projeto: Remove on each file, or Empty the list.
- Right-click the file, for example
config/appsettings.Local.json, and choose Don't commit this file. - The notice confirms: "config/appsettings.Local.json is on the "don't commit" list: it's left out of "stage all" and of the commit."
- The file leaves Unstaged files and shows up in the Don't commit (1) group. Click it to see the diff, as with any other file.
- To take it off the list, use Remove from the "don't commit" list in the menu, or the file's button in the group. The notice: "config/appsettings.Local.json was removed from the "don't commit" list."
Marking and unmarking don't run any git command that changes the repository. The list is kept in a
versora-keep.json file inside the worktree's git folder:
git rev-parse --git-path versora-keep.json # where the list's file is
It isn't a git operation and doesn't go into Ctrl+Z. To undo it, take the file off the list.
- The item doesn't show up on conflicted files or in a commit's file list.
- "The "don't commit" list holds at most 2000 files.": the list is for exceptions; for many files,
use
.gitignore(untracked files) or rethink the project's structure. - "Couldn't read the "don't commit" list: …" and "Couldn't save the "don't commit" list: …": a permission problem in the git folder. A corrupted list file counts as an empty list.
Every form of "stage all" leaves the list out:
- the Stage all changes button in the Unstaged files header;
- Ctrl+Shift+S (Stage all changes);
- Ctrl+Shift+Enter (Stage all and commit);
- the WIP row menu's Stage all changes item;
- the palette.
- Use Stage all changes as usual. The indicator shows "Staging (except the "don't commit" list)…".
- The notice says what was left out: "config/appsettings.Local.json wasn't staged: it's on the "don't commit" list." (or "2 files weren't staged ("don't commit" list): …").
- If the file should go in this time, click Stage them too in the notice itself. The indicator shows "Staging the "don't commit" list…".
git add -A -- ':/' ':(top,exclude,literal)config/appsettings.Local.json'
The exclusion is by literal path: *, ? and [ in the name count as plain characters.
Staging a file on the list by hand (the file's +, the menu, lines in the diff) is allowed: maybe this time it really should go. But the commit checks the staging area first and asks.
- Click Commit with a file on the list staged.
- The Before committing dialog shows the "Don't commit" list item: "config/appsettings.Local.json is on the "don't commit" list and is in the commit" and "Unstage the file, or remove it from the list if it really belongs in the commit."
- Cancel and unstage the file, or confirm Commit anyway.
The app rereads git's staging area at commit time, so the check also applies to a git add done in
the terminal.
- Preferences › Commit message › "Don't commit" list of meu-projeto: "Marked files (file menu › Don't commit this file) get their own group in the changes panel, are left out of "stage all" (button, Ctrl+Shift+S, Ctrl+Shift+Enter, palette), and the commit only takes them after you confirm. The list belongs to this computer and this worktree." With the list empty: "The list is empty."
- Palette: "Commit message preferences" opens the page.
- The company can hide or lock the Commit message page (id
worksafe) through thepreferences.hiddenorpreferences.lockedpolicy. See Company policy.