Skip to content


Remove Item From Git Branch

If you accidentally  put your password or underwear size on your public git repository, you may want to remove that item first get it out of future repositories by modifying the .gitignore file

mate .gitignore

add the file you don’t want to show up in the public repository, such as config/environment.rb

Then you can call this command to force the branch to be filtered. Note this command will remove the actual file from your hard drive, so make sure to have a backup.

git filter-branch --force --tree-filter  'rm config/environment.rb' HEAD

You can then push your newly super secure repository.

git push --force origin master

Posted in Ruby On Rails, Web Development. Tagged with , , , .

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.