How move all commits from specific user to a new branch?
I have 'commits' from many users. I wan开发者_如何转开发t to move all commits of some user to a new branch.
How can i do this?
Find all commits by one author and save their hash to a file:
git log --author=<author> --format=%H > /tmp/commit-by-x
Create a new branch that does not contain this particular's author commit since you don't want to apply them twice. For this, you can create a new empty branch:
git checkout --orphan commits-by-x
Cherry-pick all commits of that author (from oldest to newest):
tac /tmp/commit-by-x | while read sha; do git cherry-pick ${sha}; done
Obviously, if you want this to succeed the changes introduced by author-x have to be very localized.
精彩评论