Git Tutorial 20 – Untracked File Vs Unstaged File

Introduction

As a part of GIT Tutorials End To End, we will learn about the difference between Untracked and Unstanged files of GIT in this post.

Prerequisite posts

I will expect that you are aware of the basic concepts and commands of GIT. But if you are a beginner in GIT then I strongly recommend you to refer GIT Basic Commands and Concepts section on my blog first.

Did you know that I have started a YouTube channel as well and I need your support to make it successful. Please do watch content then comment, like, share, and obviously subscribe.

What is an Untracked File?

Let’s run some commands first. I will create a git repository using the git init command.

I will create a new file in the above git directory. You can use the Linux command or file directory to create a file.

Let’s run the git status command which will give us information about the state of the working directory.

So we have encountered the term “Untracked file”. The newly created file is shown as an Untracked file.

We know Git is a version tracking tool where a version is something how a file is changed periodically. Git will never start tracking a file until we specifically ask Git to do so. We created a new file named FileA in a Git repository i.e. “untrackedUnstaged” but Git will not track FileA by default. Git is just showing FileA as untracked. If you do any changes in FileA then also it will remain untracked till we use the git add command.

What is an Unstaged File?

Let’s use the git add command to ask Git to track FileA.

Now FileA is no more Untracked. Let’s modify the content of FileA. Again you can use the Linux command or open the file using File Directory and add some changes.

Now run the git status command.

Git is tracking changes in FileA. When we used the git add command the first time after creating FileA then FileA became a tracked or staged file with the current content/version of FileA. When we add a new line in FileA then the content of FileA is changed and Git explicitly required a confirmation from us to stage the FileA with updated content. At this point, FileA is an unstaged file. You need to use again the same git add command to mark an unstaged file to staged.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe to my YouTube channel.
#ThanksForReading
#HappyLearning

Leave a Reply

Your email address will not be published. Required fields are marked *