+14 votes
1 view
in Devops and Agile by (28.1k points)

Is there a way to add all files no matter what you do to them whether it be deleted, untracked, etc? like for a commit. I just don't want to have to git add or git rm all my files every time I commit, especially when I'm working on a large product.

2 Answers

+12 votes
by (48k points)

To add all files, modified, deleted and untracked then you could use:

git add -A

Note: 

Since git 2.0. The above command will stage all the files in the whole working tree.

If you need to stage the files in your current path you could use:

git add -A .

This will stage files in your current path.

Summary: 

git add -A stages all changes

git add .    stages the new files and modifications but not deletions.

Reference: https://git-scm.com/docs/git-add

+7 votes
by (63.4k points)

Try

git add -u

The "u" option stands for Update.

This will update the repo and really delete files from the repo that you simply have deleted in your local copy.

git add -u [filename]

to stage a delete to just one file. Once pushed, the file can not be within the repo.

Alternatively,

git add -A .

is equivalent to

git add .

git add -u .

Note the additional '.' on git add -A and git add -u. Warning: starting with git 2.0 (mid-2013), this will always stage files on the whole working tree. If you would like to stage files under the current path of your working tree, you would like to use:

git add -A 

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...