Created
July 15, 2020 03:49
-
-
Save edburns/90ec0d633ba7ee06bef98c74e0cbb2e5 to your computer and use it in GitHub Desktop.
This gist copies the last N commits from sourceBranch to destBranch.
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
sourceBranch=$1 | |
destBranch=$2 | |
numLastCommitsOnPrivateBranch=$3 | |
git checkout ${sourceBranch} | |
startingCommit=`git rev-parse HEAD` | |
endingCommit=`git rev-parse HEAD~${numLastCommitsOnPrivateBranch}` | |
git checkout ${destBranch} | |
ontoValue=`git rev-parse HEAD` | |
git rebase --onto ${ontoValue} ${endingCommit} ${startingCommit} | |
git rebase HEAD ${destBranch} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment