开发者

How to pull a series of commits in git one at a time?

I have a series of comm开发者_运维百科its in a fork that I want to apply or reject one at a time to my fork. Should I use git cherry-pick for this?


I'd use an interactive rebase for this:

git rebase -i master fork-branch

When git asks what you want to do with each of the commits, tell it edit for all of them (search and replace pick -> edit). Save and quit, and the interactive rebase will go through the commits, stopping at each to let you do your thing. Do your testing, decide if you want to keep it. If you do, just run git rebase --continue to move on to the next. If you don't, run git reset --hard HEAD^ to reset to the previous commit, throwing away the one you don't want, then move on to git rebase --continue.

If there are commits you know right away you don't want, you can just remove them from the list instead of changing pick to edit. And of course, if I've completely misunderstood, and you don't need to do any testing, then you can pretty much disregard the previous paragraph, and do it all by selectively removing lines.


Yes. git cherry-pick COMMIT_SHA will allow you to grab a specific commit. You don't need to reject commits, though; just don't cherry pick them.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜