Skip to content

Instantly share code, notes, and snippets.

@gtzilla
Created January 25, 2011 07:15
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtzilla/794615 to your computer and use it in GitHub Desktop.
Save gtzilla/794615 to your computer and use it in GitHub Desktop.
instructions I need to merge git commits together
http://stackoverflow.com/questions/598672/git-how-to-squash-the-first-two-commits
# Go back to the last commit that we want to form the initial commit (detach HEAD)
git checkout <sha1_for_B>
# reset the branch pointer to the initial commit,
# but leaving the index and working tree intact.
git reset --soft <sha1_for_A>
# amend the initial tree using the tree from 'B'
git commit --amend
# temporarily tag this new initial commit
# (or you could remember the new commit sha1 manually)
git tag tmp
# go back to the original branch (assume master for this example)
git checkout master
# Replay all the commits after B onto the new initial commit
git rebase --onto tmp <sha1_for_B>
# remove the temporary tag
git tag -d tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment