Antoine
Antoine

Reputation: 4029

Add only modified already staged files

How do I re-add files that are staged, but then I modified after staging? I don't want to add them manually one by one.

$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

 modified:   file1
 modified:   file2

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

 modified:   file1
 modified:   file3

Here I don't want file3 to be staged.

Upvotes: 2

Views: 105

Answers (1)

Antoine
Antoine

Reputation: 4029

Turns out git update-index has an option just for that:

git update-index --again

Runs git update-index itself on the paths whose index entries are different from those from the HEAD commit.

Sources:

Upvotes: 3

Related Questions