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.
notepad++ hipster.txtand 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.
git statuswe can see that we have a modified file.
git commit -amwhere -a will add a file to staging area and m for my commit message.
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 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.
git add newfile.txtthen
git statustells me that the changes are to be committed.
git ls-filesthen, you will see newfile.txt has listed in that.