Created
September 5, 2018 18:53
-
-
Save ethanj/be15cdc17bd88cfca6551d5ece8fe957 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# work on new dependent branch (newbranch) while waiting to merge pr on dependent branch (prbranch) | |
git checkout -b newbranch | |
# equiv to following if not on prbranch | |
git checkout -b newbranch prbranch | |
#do work on newbranch | |
# lets say pr needs mods | |
gco prbranch | |
# do edits | |
# commit changes to prbranch | |
gcam "cleanup for pr" | |
git push origin prbranch | |
# incorporate changes to prbranch into newbranch | |
gco newbranch | |
git rebase prbranch | |
# resolve conflicts if present (git add + git rebase --continue) | |
# pr gets approved | |
# squash and merge prbranch in github | |
# important non-obvious way to "rebase" newbranch to result of prbranches merge | |
# on newbranch, squash newbranch commits into one commit | |
git log | |
# search for the commit right before newbranch commit | |
git rebase -i <sha of previous commit> | |
# change first letter of each line to 's' | |
# retrieve sha of the resulting squashed commit for use later, aka 'newsha' | |
git log | |
gco master | |
git pull | |
# rename newbranch to a temp name, since we will create a new branch based on it | |
git branch -m newbranch newbranch-tmp | |
# recreate our new branch | |
gco -b newbranch | |
# cherry pick the squashed commit from newbranch-tmp to newbranch | |
git cherry-pick <newsha> | |
# force push newbranch to github otherwise it will reject it | |
git push origin newbranch -f | |
# newbranch is now normal | |
# pr gets merged | |
# Rebase new branch onto master | |
git pull --rebase origin master | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment