tags:

views:

39

answers:

2

I realized that in a old commit I made some modifications to a file that I partially regret and I don't want anyone to see.

The changes for that file in this commit are not all bad, so I need to keep the good ones and this prevents me from simply removing the commit entirely.

My goal is to remove the bad lines completely from history without affecting the good ones. How can this be accomplished? Thanks

A: 

Maybe git rebase can help you?

Simon Groenewolt
A: 

git rebase -i does what you want. Running it in interactive mode will bring up an editor that will allow you to edit or completely remove commits from the repo history. Here's an example:

http://blog.madism.org/index.php/2007/09/09/138-git-awsome-ness-git-rebase-interactive

Alex M.
Thanks, didn't know about the edit functionality with git rebase -i. Anyway since I was in a hurry and couldnt wait for suggestions any longer I removed the crap in a subsequent commit, rebased -i and squashed the commits in between, and any trace of the undesired code seem to have vanished. That's what git log -p says. A couple of lessons learned about git.
spaghetticode