Search anything:

Git Status command: File stages in Git

Binary Tree book by OpenGenus

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.

OpenGenus loves Git

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 and untracked files

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
committed, modified and staged files git

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.

OpenGenus Tech Review Team

OpenGenus Tech Review Team

The official account of OpenGenus's Technical Review Team. This team review all technical articles and incorporates peer feedback. The team consist of experts in the leading domains of Computing.

Read More

Improved & Reviewed by:

Git Status command: File stages in Git
Share this