Thursday, March 16, 2017

How to remove deleted files from git

So I deleted few files from my repo and yet I still saw them each time I executed 'git status', I was annoyed so I decided to fix it!

Here is what you do: You need to remove the deleted files from git and then issue another commit to finalize the change.
First you need to find the name of these files. Here is a script to do it

git status | grep deleted | awk '{print $3}'

this would issue 'git status' command, find all that say deleted, and then extract file names.

Now feed that to git remove command, like so

git rm `git status | grep deleted | awk '{print $3}'`

Now commit the change and you are all set!

No comments:

Post a Comment