git add command explained with examples
Introduction In our last article, we explained how to add content to a local git repository. There we used the git add command to add the README.md file to the repository we initialized with git. In this article, we will talk about the git add command in greater detail and will also demonstrate some common options used with the git add command with examples. What does the ‘git add’ command really do? This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit. A “working tree” consist of files in the repository that you are currently working on. An “index” is the staging area where new commits are prepared. It acts as the interface between a repository and a working tree. The index holds a snapshot of the content of the working tree, and it is this snapshot that is taken as the contents of the next commit. Thus after making any changes to the working directory, and before running the commit command, you must use the add command to add any new or modified files to the index. The git add command can be performed multiple times before a commit. It only adds the content of the specified file(s) at the time the add command is run; if you want subsequent changes included in the next...
Read More