Friday, May 11, 2018

git commit all deleted files at one time


There are couple of options to do batch commit of deleted files.

git add .  => Add all (tracked and modified)/new files in the working tree.

git add -u => Add all modified/removed files which are tracked. (stages removed file and modifiled files, then git commit -m 'message')

git add -u folder/ => Add modified/removed files under the folder

git add -A => Add all (tracked and modified)/(tracked and removed)/new files in the working tree. (similar to git add -u, but also adds new files.)

git commit -a -m "commit message" - Add and commit modified/removed files which are tracked.

git ls-files --deleted -z | xargs -0 git rm
git rm $(git ls-files --deleted)

My personal perfer is git add -A and git add -u

No comments:

Post a Comment