On Github tommygnr / git-rebase-talk
Tom Corrigan / @tommygnr
Rebase is the alternative (to git merge) way to integrate changes on two branches
You have worked on a big feature in your own branch. Meanwhile development work has continued on master. You need to take advantage of some of that work.
git fetch git rebase origin/masterInteractive rebase lets you tidy up, reorder, remove and amend commits
git rebase -i HEAD~5You do some work, commit. Do a bit more work, commit. Notice a silly mistake in the first commit. You want to fix the mistake and make it part of the first commit
git commit -m "shiny new feature" git commit -m "second shiny feature" git commit --fixup=HEAD~1
git rebase -i --autosquash HEAD~2The following can save you a few keystrokes and is extremely safe
git config --global rebase.autoSquash trueUse the below with care: the final stash application after a successful rebase might result in non-trivial conflicts.
git config --global rebase.autoStash trueNever rewrite history you have shared with others!
Definition of shared is somewhat fuzzy. In my opinion you should rebase pull requests.
https://pcottle.github.io/learnGitBranching/
https://git-scm.com/docs/git-rebase
I will make the slides available on my Speaker Deck account and post a link to the meetup page