I was assuming that both work in the same way. Both add every file onto index. But I seem wrong.
- What's the difference between
git add .
andgit add -u
?
I was assuming that both work in the same way. Both add every file onto index. But I seem wrong.
git add .
and git add -u
?Like the manual says: git add .
will add all files in you current directory, while git add -u .
will only add those already being tracked.
git add .
add all files from the current directory
git add -u
only update files currently being tracked.
It is one of git gotcha mentioned here
git add .
only add what is there, not what has been deleted (if tracked).
git add .
git commit
git status
//hey! why didn't it commit my deletes?, Oh yeah, silly me
git add -u
git commit --amend
git add -A
would take care of both steps...