Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After resolving conflicts how to 'git add' all the resolved files

Tags:

git

So one thing that happens to every now and then, is:

  • doing a git merge <some-branch>
  • have multiple conflicts
  • resolve those conflicts manually using a text editor
  • git add all the individual files

I want to ask about is this last step. I know I can do a git add ., but I may have some loose files laying around that I do not want added to version control.

Is there a command, alias, or some way you know to only add the previously conflicting files?

like image 842
Pedro Lopes Avatar asked Jul 24 '14 17:07

Pedro Lopes


People also ask

How do I continue rebase after a conflict?

To fix the conflict, you can follow the standard procedures for resolving merge conflicts from the command line. When you're finished, you'll need to call git rebase --continue in order for Git to continue processing the rest of the rebase.


1 Answers

If you have some files that you don’t want added, but don’t have any such non-conflicting changes, then you can use git add --update:

git add -u .

From git-add(1):

-u, --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.

If no <pathspec> is given when -u option is used, all tracked files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).

like image 90
Ry- Avatar answered Oct 20 '22 08:10

Ry-