Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
346 views
in Technique[技术] by (71.8m points)

git - rebase reverted merged branch

Background: I recently merged a rather large topic branch into master. A couple of days later I discovered this topic branch contained bugs. So I git revert -m 1 <merge-commit>ed it.

Problem: Now I'd like to check out the topic branch and rebase it against current master so that I can 1) fix the bugs and 2) (again) merge the fixed up topic branch with master. Creating the new branch, fixedtopic is the easy part, but every time I do

git checkout fixedtopic
git rebase master

git decides that it's not willing to replay the old commits since they are already merged into master. Instead it simply does a fast-forward rebase.

Question: How can force replay of the commits onto fixedtopic using rebase? Can I? I'd rather not use cherry-pick since it's a bit more cumbersome.

Additional:

  • git reseting the merge commit it not an option, since I have pushed the master upstream.
  • I'd rather not create a new branch off of master and revert my revert. The reason for this is that I'd like to rewrite some of the topic branch's history using interactive rebase.
  • Here's a github gist of the scenario: https://gist.github.com/JensRantil/6352495 Note that I'd like e8df5ec and ee16464 applied onto master (or branch based on master).
question from:https://stackoverflow.com/questions/18462765/rebase-reverted-merged-branch

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

One way to achieve this is to interactively rebase the topic branch and reword the first commit after branching out of master (e.g. git rebase -i HEAD~10 if you have 10 commits in the branch). This will rewrite sha's of all the commits inside the topic branch. Therefore you will be able to rebase the usual way with git rebase master.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...