git.day/2 • See all at git.day
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:
| Invocation | Command | Description | Equivalent |
|---|---|---|---|
| 1 or s | status | show paths with changes | git status |
| 2 or u | update | add working tree state to the staged set of changes | git add |
| 3 or r | revert | revert staged set of changes back to the HEAD version | git reset |
| 4 or a | add untracked | add contents of untracked files to the staged set of changes | git add |
| 5 or p | patch | pick hunks and update selectively | git add -p |
| 6 or d | diff | view diff between HEAD and index | git diff |
| 7 or q | quit | bye | |
| 8 or h | help | this |
All these options are available with direct commands instead, but this interactive session makes it easy to find out about these options.
- Running
git add …in Terminal runs thegit-addbinary with the remaining arguments. ↩︎

Leave a Reply