Is there a way to stage or unstage (git add
/ git rm
) files only based on what was the type of modification?
Like :
Based on the other linked answer you can do (in bash)
git diff --name-only --diff-filter=D | xargs git add
to e.g. only add deleted files.
You can use the other diff-filter options for modified, new, renamed files etc. And of course you can swap out git add
for git reset
etc.
--diff-filter=[ACDMRTUXB*]
Select only files that are
A
AddedC
CopiedD
DeletedM
ModifiedR
RenamedT
have their type (mode) changedU
UnmergedX
UnknownB
have had their pairing Broken*
All-or-noneAny combination of the filter characters may be used.