Is it possible in Git to only stage files that have already been staged, but have been modified since?
For example, given:
> 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: file2
modified: file3
Is it possible to tell Git to only stage file2
without specifying file2
(e.g. not git add file2
or something similar)?
Looking beyond git add
, you can do:
git update-index --again
From the docs:
Runs
git update-index
itself on the paths whose index entries are different from those from theHEAD
commit.
which, as it turns out, is exactly what we need here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With