Open-Source Internship opportunity by OpenGenus for programmers. Apply now.
Reading time: 15 minutes
Git takes a look at changes in a git repository in two different views. We will explore this in this article.
Now that our local repository is equal to our origin repository, we are ready to make some new changes in these files.
Each file in our project can be in one of two states. It can be:
- tracked by Git
- untracked by Git
Tracked files are ones that were in the previous Git snapshot. Tracked files can be in one of three states:
- committed, which are unmodified changes from the last snapshot
- modified, which are files that we've added changes to
- staged, which are files that we've marked to be added to our next commit snapshot
When we make a change to our committed or unmodified file, it moves from a committed stage and into the modified stage. When we are satisfied with our changes and we want to stage them for commit, we add them to our staging area. We then take the changes in the staged area and commit them to our repository. These changes are now saved in our repository in that commit snapshot. and they are then moved back to the committed stage.
Now, going back to the Terminal command line, we can run git status and see which files are in which state. Now since we have nothing yet to commit, and our working tree, again, is clean, and all files are in the committed state from the last snapshot, as we make changes to the project, keep in mind the three stages and see if you can predict the state of file.