I am learning Git commands.
My understanding of git add and git commit is as follows: git add 'file name' takes snapshot of the project(entire working directory) and stage it. git commit saves the staged snapshot to the repository.
I also understand that git differs from SVN etc in the fundamental way of saving the files. While SVN saves incremental changes in individual files, git saves snapshot of the entire working directory. If a file has not changed, git snapshot would contain a reference that file in the previous snapshot.
I have a question here. If git add takes snapshot of entire working directory why do we need to provide individual file name in the command? Git would anyway take snapshot of entire project.
git add file [file ...]adds only the specified files, not the entire working directory. But it does allow you to specify a directory, which means "all files in the directory"; and if you are at the top of your work tree and specify., that amounts to "all files in the work tree". There are some exceptions here due to.gitignorefiles and the like, but that covers most of it.git add -uto add all previous-tracked files.git add -A.