Skip to content

Instantly share code, notes, and snippets.

@dennis90
Created October 8, 2017 18:56
Show Gist options
  • Save dennis90/88f9cd276f04829dc7e7b8b264900db2 to your computer and use it in GitHub Desktop.
Save dennis90/88f9cd276f04829dc7e7b8b264900db2 to your computer and use it in GitHub Desktop.
What to do when you push to the wrong branch

Oh shit, I accidentally pushed to the wrong branch

# get the hashes from the wrong commits with git log

# then revert this commits:
git revert last-commit-hash

# create the correct branch and then checkout to then
git checkout -b right-branch

# then you can re-apply the wrong commit to the right branch
git cherry-pick last-commit-hash

# then all you need is to push the changes and it's done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment