Git: How to add an untracked file back to the repository?

If you want to add certain files that was previously removed from Git repository, follow the steps given below.

STEP 1: remove the file reference in .gitignore

STEP 2: remove the cached reference from git.

$ git rm –cached sampleconfig.txt

STEP 3: add the file to Git repository

$ git add sampleconfig.txt

$ git commit -am “Adding sampleconfig back to git commit”

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Written by kurinchilamp


Website: http://

Leave a Reply

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

Kurinchi Calendar
October 2017
M T W T F S S
« Jul    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
Read previous post:
Git: How to make a file not to be tracked in future commits?

As a developer, you may come across scenarios when you think that certain SPECIAL files should not be tracked in...

Close