Search code examples
gitrebase

git add option like -a for git commit


During a long rebase (say, for an integration branch with lots of commits to the main development branch), I frequently have to git add all of the files with conflicts that I've resolved.

Recently I tried git add -all thinking it would be like git commit -a but no luck: it also added any untracked files I happened to have.

I need to add all tracked files that were modified during the (partial) rebase, before using git rebase --continue. Is there a simple way to get the list of files that would be added by git commit -a? Then I could use this list at the end of git add.


Solution

  • git add -u (short for --update):

    Update the index just where it already has an entry matching <pathspec>. This removes as well as modifies index entries to match the working tree, but adds no new files. (emphasis mine)

    "Update the index" is Git parlance for "stage the changes". I tried it in a new repo and conflicting files are staged too, so it would fit your use case.