George Garside Blog

A place of many ramblings about macOS and development. If you find something useful on here, it's probably an accident. • See all at

When learning Git for the first time, there can be a lot of options to learn. git-add1 has an option, --interactive or -i for short, that starts an interactive session.

The output begins with a similar summary to git status:

$ git add -i
           staged     unstaged path
  1:    unchanged        +1/-0 file.txt

Then what follows is a list of options that you can take by pressing the corresponding number or first letter of the option at the ‘What now’ prompt.

*** Commands ***
  1: [s]tatus     2: [u]pdate      3: [r]evert     4: [a]dd untracked
  5: [p]atch      6: [d]iff        7: [q]uit       8: [h]elp
What now>Code language: CSS (css)

Here’s a brief explanation of each command:

1 or sstatusshow paths with changesgit status
2 or uupdateadd working tree state to the staged set of changesgit add
3 or rrevertrevert staged set of changes back to the HEAD versiongit reset
4 or aadd untrackedadd contents of untracked files to the staged set of changesgit add
5 or ppatchpick hunks and update selectivelygit add -p
6 or ddiffview diff between HEAD and indexgit diff
7 or qquitbye
8 or hhelpthis

All these options are available with direct commands instead, but this interactive session makes it easy to find out about these options.

  1. Running git add … in Terminal runs the git-add binary with the remaining arguments. ↩︎

Leave a Reply

No comments