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.

- 14,023
- 6
- 43
- 67

- 2,801
- 2
- 17
- 4
-
8See: [Difference of “git add -A” and “git add .”](http://stackoverflow.com/questions/572549/difference-of-git-add-a-and-git-add) – mahalie Jun 07 '11 at 01:14
10 Answers
Try:
git add -A
Warning: Starting with git 2.0 (mid 2013), this will always stage files on the whole working tree.
If you want to stage files under the current path of your working tree, you need to use:
git add -A .
Also see: Difference of git add -A
and git add .
-
this did not work for me... how can i show my terminal input-output in this discussion? copy-paste my terminal output as an answer to this discussion? – Rakib Oct 11 '11 at 12:29
-
here is the problem i am facing - http://stackoverflow.com/q/7726131/636762 - kindly help me on this one please – Rakib Oct 11 '11 at 12:41
-
This can also not work if your git version is old. I was running a script on a server that was running git 1.5.2.5. git add -A was not working. From the script, no error message was reported. Only from the command line did I find that -A was not a legal option to add. – Eponymous Jan 16 '12 at 16:37
-
but why do i have to add files everytime I want to make a commit!? Everytime I made changes to a files to I need to add it.. – Frade Apr 06 '15 at 22:39
-
3This is just how Git works. You have to add changes to your staging area before you commit it. For example, you can add only some files to a commit and provide comments for it, instead of all files all the time. Here's a handy explanation of what this is doing and why: http://gitready.com/beginner/2009/01/18/the-staging-area.html – Kilanash Apr 07 '15 at 16:08
Try
git add -u
The "u
" option stands for update. This will update the repo and actually delete files from the repo that you have deleted in your local copy.
git add -u [filename]
to stage a delete to just one file. Once pushed, the file will no longer be in the repo.
Alternatively,
git add -A .
is equivalent to
git add .
git add -u .
Note the extra '.' 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 want to stage files under the current path of your working tree, you need to use:
git add -A .
Also see: Difference of git add -A
and git add .

- 1
- 1

- 1,982
- 18
- 23
The following answer only applies to Git version 1.x, but to Git version 2.x.
You want git add -A
:
git add -A
stages All;
git add .
stages new and modified, without deleted;
git add -u
stages modified and deleted, without new.
-
1Note the above only applies to Git 1.x. For git version 2.x, `git add -A` is equivalent to `git add .`. See [here](https://stackoverflow.com/questions/572549/difference-between-git-add-a-and-git-add) for more discussions. – jdhao Apr 23 '20 at 04:58
git add --all
or git add -A
or git add -A .
Stages All
git add .
Stages New & Modified But Without Deleted
git add -u
Stages Modified & Deleted But Without New
git commit -a
Means git add -u
And git commit -m "message"
After writing this command follow these steps:-
- press i
- write your message
- press esc
- press :wq
- press enter
git add <list of files>
add specific file
git add *.txt
add all the txt files in current directory
git add docs/*/txt
add all txt files in docs directory
git add docs/
add all files in docs directory
git add "*.txt"
or git add '*.txt'
add all the files in the whole project

- 10,936
- 8
- 64
- 79

- 1,661
- 2
- 18
- 20
I'm not sure if it will add deleted files, but git add .
from the root will add all untracked files.

- 7,150
- 2
- 28
- 37
For newer version of Git.
I tried git add -A
and this prompted,
warning: The behavior of 'git add --all (or -A)' with no path argument from a subdirectory of the tree will change in Git 2.0 and should not be used anymore. To add content for the whole tree, run:
git add --all :/ (or git add -A :/)
To restrict the command to the current directory, run:
git add --all . (or git add -A .)
With the current Git version, the command is restricted to the current directory.
Then I tried below which worked.
git add --all :/

- 8,780
- 3
- 42
- 47
I authored the G2 project, a friendly environment for the command line git lover.
Please get the project from github - G2 https://github.com/orefalo/g2
It has a bunch of handy commands, one of them being exactly what your are looking for: freeze
freeze - Freeze all files in the repository (additions, deletions, modifications) to the staging area, thus staging that content for inclusion in the next commit. Also accept a specific path as parameter

- 50,287
- 22
- 91
- 122
This is my alternative (in any bash):
$ git status -s|awk '{ print $2 }'|xargs git add
To reset
$ git status -s|awk '{ print $2 }'|xargs git reset HEAD

- 7,144
- 3
- 31
- 48
I use the following line to add for staging all the modified and newly created files, excluding the ones listed in .gitignore:
git add $(git ls-files -mo --exclude-standard)
(the syntax $() is for the bash shell). I guess that the command line option -mod should add also the deleted files... Or, if you have file names with embedded blanks, the following one-liner should do the trick:
git ls-files -z --deleted --modified --others --exclude-standard | xargs -0 git add

- 161
- 4
From Git documentation starting from version 2.0:
To add content for the whole tree, run:
git add --all :/
or
git add -A :/
To restrict the command to the current directory, run:
git add --all .
or
git add -A .

- 795
- 7
- 17