Table of content

Git Tracked Files

Git Tracked file is a file that Git is aware of it and tracking activities and any file that is already been committed to the Git repository or any file that is been added to Git Index or Git staging area is called a Tracked file.

The way to find out whether your files have been tracked by Git is to use the command git ls-files, This command gives me the list of all the files that Git is tracking in the current repository.

So how to track the files through Git which are present in the staging area is as shown below :

Open Git bash command prompt and give pwd to check where you are, so am currently in my projects folder because all my projects are under the projects folder.

Next, give command ls there you can see starter-web-1/ folder, now give cd starter-web-1/ you will be directed to that folder.

If you do git status, Git tells us that the working directory is clean, and hence, let us start a new project.

  • So here we had already started with a .txt file hipster.txt, so we will continue editing the same file.
  • In the command prompt type notepad++ hipster.txt and press enter, you are directed to notepad page, now let us open the hipster ipsum website and copy some dummy text and paste it in the notepad page then save and exit.
  • If you do,git status we can see that we have a modified file.
  • Here I wanted to do a shortcut, the add and commit process through one command by using
    git commit -am where -a will add a file to staging area and m for my commit message.
  • I am doing inline commit message as adding some more Ipsum text and press enter
    git commit -am "Adding some more ipsum text"

where -a parameter will add any changes that are modified into the staging area, and then committing directly. This process can be done only when the files are being tracked. The Files can be tracked by using the command git ls-files.

  • Am Going to create another .txt file named newfile.txt and adding some dummy text into it.
  • If I do git status, Git tells me that I have an untracked file and if you do git ls-files, the newfile.txt has not listed in that.
  • So I do,git add newfile.txt then git status tells me that the changes are to be committed.
  • Hence we have added this file to the staging area, now do git ls-files then, you will see newfile.txt has listed in that.

Recursively Adding Files To Git Repository