Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save amalrik/4e751ff4397a78a1d35f to your computer and use it in GitHub Desktop.
Save amalrik/4e751ff4397a78a1d35f to your computer and use it in GitHub Desktop.
# inspired by https://mriet.wordpress.com/2012/07/01/merge-bubbles-are-bad/
# and http://snipplr.com/view/26715/
# 1. first rebase all your local commits into one commit, e.g. for the last 3 commits into one you can use
git rebase -i HEAD~3
# and 'pick' the first, 'squash' the other commits
# 2. check the commit's sha id and save it somewhere
git log --oneline
# 3. rollback your single (main) commit using
git reset --hard HEAD^1
# 4. pull from origin to get the latest upstream changes (via fast forward)
git pull
# 5. cherry pick your rolled back commit to apply it on top of the updated sources
git cherry pick rolled_back_comit_id
# 6. now you can push it
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment