In my Git repo, I changed some files. I want to stage all of them. But is there a difference between commands:
git add file1.php file2.php
git add .
开发者_JAVA百科
Does the second command stage only modified files, or all files from project? Or these commands are equal?
git add file1.php file2.php
stages the files file1.php
and file2.php
.
git add .
stages all files in the directory and all subdirectories, including uncommitted ones. (As long as they're not ignored by your .gitignore
)
Either command will only stage a file if it's been modified, however.
If file1.php
and file2.php
are the only files that have changed or are untracked the two commands are equivalent, because unchanged files can't be staged anyway.
As explained by Sebastian P., these commands are not equavalent.
To stage all modified files, you can use git add -u
Also, for a quick commit of all modified files, you can use git commit -a
which is equivalent to git add -u ; git commmit
精彩评论