Thursday, February 7, 2013

Git rewrite history to Github

To remove the last commit from the master branch at Github but "saving" that last commit to a branch named mein-bak

[master]> git checkout -b mein-bak
[mein-bak]> git push origin mein-bak
[mein-bak]> git checkout master
[master]> git reset --hard HEAD~1
[master]> git push --force origin master

Before applying changes this is how master looks at Github:

a-b-c-d-e-f-g [master]

And this is how it looks after applying those changes:

a-b-c-d-e-f [master]
            g [mein-bak]

No comments: