开发者

Can cherry-picking from a branch cause trouble rebasing this branch to master

Context: I have an experimental branch crazy-idea where I did some wild things in a dedicated sub-dir madness/{src,docs}. A ton of commits, with notes, pictures, hacky scripts to create plots. Now that I have fully understood what I'm doing it's time to edit the actual source files in src/ by adding new functions and alter existing ones.

Since the mess in crazy-idea would clutter the history of master, a new branch good-idea was created to merge the changes in src/ into master. Convince suggests that I alter the files in src/ still being in crazy-idea and then cherry-pick the commits from within good-idea.

Now my question: Given that good-idea was merged into master and some commits were done in master after this event. When I go back to crazy-idea to further iron out some other aspect of my idea, is there trouble to be expected in src/ while rebasing to master?

The alternative is to leave src/ within crazy-idea alone, make a copy of the sub-dir and look at my notes this way while coding directly in good-idea.

What do you guys suggest is smarter?

EDIT Well, as expected I got conflicts during

git rebase master

in crazy-idea. In future I will introduce changes only in exactly one branch and use cherry-picking only when I know that it's more or less abandoned.

EDIT I solved my situation as follows: There have been N commits with changes in src/. Lets say the last non src/ changing commit had the message 'foobar'. After the rebase failed:

$ git rebase --abort
$ git reset --hard HEAD^
HEAD is now at ...
# more hard resets, I think actually N
HEAD is now at ... fo开发者_如何学Pythonobar
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying ..
...

Done. This evidently isn't as straight forward as I hoped, but not too bad either. I think I will go this route instead of copying madness/.


Git should not have very much trouble reconciling the cherry-picks. When rebasing, Git will ignore any commits (and even hunks within a commit's diff) that introduce change that has already been introduced on the target branch.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜