开发者

How move all commits from specific user to a new branch?

开发者 https://www.devze.com 2023-02-20 23:40 出处:网络
I have \'commits\' from many users. I wan开发者_如何转开发t to move all commits of some 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号