Is it redundant to run git add .
and then git commit -am \"commit message\"
?
Can I just run git add .
and then git commit -m
I think some of the previous answers did not see the period after git add
(your original question and some of the answers have since been edited to make the period more clear).
git add .
will add all files in the current directory (and any subdirectories) to the index (except those being ignored by .gitignore
).
The -a
option to git commit
will include all changes to files that are already being tracked by git, even if those changes have not been added to the index yet.
Consequently, if all of the files are already being tracked by git, then the two approaches have the same effect. On the other hand, if new files have been created, then git add .; git commit
will add them to the repository, while git commit -a
will not.
git add .; git commit -a
is indeed redundant. All changes have already been added to the index, so the -a
does nothing.