Back

Explore Courses Blog Tutorials Interview Questions
+12 votes
3 views
in DevOps and Agile by (29.3k 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

+10 votes
by (50.2k 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

+5 votes
by (62.9k 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 

Browse Categories

...