-
-
Save KharmaScribbles/89fda522f1b8c2ad87312626b777e17f to your computer and use it in GitHub Desktop.
Cherry-picks commits from master that have changes to specified files.
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
$!/usr/bin/env sh | |
branch=`git symbolic-ref --short HEAD` | |
git checkout master | |
commits=`git log --pretty="%H" --reverse -- $*` | |
git checkout $branch | |
for commit in $commits; do | |
git cherry-pick $commit | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
Create the clean branch:
$ git checkout --orphan my-new-branch
$ git rm -rf .
Create an initial commit, because cherry-pick doesn't work on an empty head.
Now, assuming you're still in the "my-new-branch" branch, run
$ git-pick-file.sh file1 file2 fileX
Then to make sure everything worked as planned, check
$ git log