Skip to content

Instantly share code, notes, and snippets.

@laszlomiklosik
Created October 15, 2012 20:51
Show Gist options
  • Save laszlomiklosik/3895381 to your computer and use it in GitHub Desktop.
Save laszlomiklosik/3895381 to your computer and use it in GitHub Desktop.
How to avoid Git merge bubbles
# 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
@laszlomiklosik
Copy link
Author

  1. another option is to always use:

git pull --rebase

when pulling from upstream.
2. An even better idea is to work on local_branch and rebase that often with data from upstream using the below while being on local_branch:

git rebase master
git checkout master
git merge local_branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment