Yesterday my teammate accidentally has committed a bad change leaking some credentials during the merge (a rough reconstruction):
# bad commit reconstruction
$ git pull
... no automatic merge happened ...
... some manual merge goes here ...
$ git add . # instead of `git add src`
$ git commit -m "merged"
and then committed another non-merge good change, but didn't push the changes:
# good commit reconstruction
... edit ...
$ git add .
$ git commit -m "foo bar"
I would like to modify the bad commit so the credentials could not be pushed to the remote repository. Since local commits are not pushed yet, first of all, I tried this solution using git rebase --interactive HEAD~2
(an old SVN-user hoping to rebase these bad and good revisions only), but it seems not to work showing more commits than expected (the ones that have been pulled) and fully omitting that bad commit. As far as I understand it does not work because of the merge. The current tree is as follows:
* GOOD [master]
|
* merge + BAD
|\
| |
| * pulled [remote/origin/master]
| |
| * pulled
| |
| * pulled
| |
| * pulled
How can I modify the bad commit excluding the files containing sensitive data so it could become a good commit as well and ready to push?