Add the deleted file back and do not track it.

One of our developers used git rm config instead of git rm --cached config , and now every time we check this branch, the "config" file is deleted. I tried this spell to try and prevent git from deleting the file, unsuccessfully:

 git add -f config git commit -m "fixing config file issue" git pull git push git rm --cached config echo "config" >> .gitignore git add -u git commit -m "fixing config file issue part 2" git push 

How to stop git from deleting this file from our local repositories with each check?

+4
source share
2 answers

How about this sir

 $ git revert HEAD [master af2e8fd] Revert "erroneous removal" 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 config 

Also I just noticed getting config from .gitignore ! You want to track it.

+1
source

If you don’t need to change the commit history, you can

 git checkout HEAD~ config 

where HEAD ~ means the last commit there config should be intact. (If not, check HEAD ~ 2, which means the last last commit. man gitrevisions to complete.)

Then config should return, execute

 git commit -m 'config issue fixed' 

.

+1
source

All Articles