Undo Git Commit

Posted by Chris Barnes Sun, 18 Apr 2010 12:00:00 GMT

I just made a commit to a public project and pushed the changes up to github. Then I realized that I left some confidential information in one of the files. Searching online lead to a couple of different ways to fix this (git rebase, and git filter-branch), neither of which were working well for me.

I finally figured out that doing the following would work as long as the confidential information were only included in the last commit.

First update the file and remove the confidential info.

git add my-file-with-confidential-info

git commit --amend
(this will add what's in your current staging area to the last commit)

git push origin +master
(force push your changes to github)

Hope this helps someone else.

Trackbacks

Use the following link to trackback from your own site:
http://blog.randomutterings.com/articles/trackback/34

Comments - Leave a response

  1. Avatar
    Beats Headphones 7 months later:
    bravo à vous deux !!! pas mal votre idéé de faire sponsorisé votre mariage !!jje vous souhaite tout le bonheur du monde !!! vous etiez magnifique !!! que de beaux souvenirs pour vous !!! soyez heureux bisous odile de marseille
  2. Avatar
    cheap tiffany co jewelry 11 months later:
    I am profoundly grateful, touched by the great distinction and honor and great compliment accorded me by the authorities of Harvard this morning. I am overwhelmed, as a matter of fact, and I am rather fearful of my inability to maintain such a high rating as you've been generous enough to accord to me. In these historic and lovely surroundings, this perfect day, and this very wonderful assembly, it is a tremendously impressive thing to an individual in my position.tiffany and co outlet
  3. Avatar
    Sildenafil about 1 year later:
    Merci pour cet excellent article qui va directement à l’essentiel. …