kabir kPro Student 18,036 Points
Before committing, adding our work twice?
In the video "Marking Todo Items Complete" (8:20), I thought
-am stands for
add, why are we adding our work twice, before committing them?
Here are the commands in question for adding our work,
treehouse:~/projects/odot (master *) $ git add . treehouse:~/projects/odot (master +) $ git commit -am "Mark todo item as complete"
Kevin Korte28,094 Points
There is a bit of a difference.
-a flag to the commit causes git to stage every file already tracked. This would not include new files that have not already been tracked.
git add . stages already tracked files, and tracks modification to new files, and adds new files in. It does not stage any deleted files though.
So, in laymen terms,
Git stage new and modified files, without deleted git commit all staged files.
It is a bit redundant, but it is what it is. You this case, if you would have just ran
git commit -am you would have committed all files already tracked, but not commited any untracked (i.e. new files), which might be helpful at some point.
I'd encourage you to read about the different
git add -A,
git add .,
git add -u, etc options, I really think this answer does a good job.
This is a bit more dry, but it's official docs, and very thorough : https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository