gf50uw
Last Updated: April 11, 2016
·
34.84K
· manojlds
Dcbad5e0bb2af6ced698ea8e3cf9c450

Add all modified files in git - the easy way

I recently saw a protip that use git ls-files to add modified files. Like so:

git ls-files --modified | xargs git add

You don't have to do that!

All you need to do is:

git add -u

Done!

Say Thanks
Respond

3 Responses
Add your response

5049
15927fc52919e9223adc7ed99e125d4d

If you delete files, you will also need to do git add ..

I prefer to use git add -A which does git add . && git add -u.

over 1 year ago ·
5064
Dcbad5e0bb2af6ced698ea8e3cf9c450

@twolfson From the docs:

Only match <filepattern> against already tracked files in the index rather than the working tree. That means that it will never stage new files, but that it will stage modified new contents of tracked files and that it will remove files from the index if the corresponding files in the working tree have been removed.

That does mean that git add -u stages deletions too. These commands take in an optional <filepattern> and when that is not given, it is by default .

git add -A add all files, including untracked ones.

over 1 year ago ·
5065
15927fc52919e9223adc7ed99e125d4d

@manojlds Ah, correct you are (I just tried it too).

I think I must have misread my git status one time and considered that my lesson learned.

over 1 year ago ·
Filed Under