Tuesday, May 24, 2016

GIT: Accidentally amended a commit that was already pushed? Here's how to fix it.

git reset HEAD^ --mixed // delete the latest local commit, but keep the working directory
git stash save // stash away working directory changes
git pull // pull the remote commit that you originally amended
git stash apply // apply the stash on it
git add -u // stage the changes
git commit // commit the changes that you originally amended to a new commit

No comments:

Post a Comment