Git: How to rebase to a specific commit?

后端 未结 9 619

I\'d like to rebase to a specific commit, not to a HEAD of the other branch:

A --- B --- C          master
 \\
  \\-- D                topic
<
9条回答
  •  旧时难觅i
    2020-12-07 08:29

    I've used a mixture of solutions described above:

    $ git branch temp 
    $ git rebase --onto temp master topic
    $ git branch -d temp
    

    I found it much easier to read and understand. The accepted solution lead me to a merge conflict (too lazy to fix by hand):

    $ git rebase temp
    First, rewinding head to replay your work on top of it...
    Applying: 
    Using index info to reconstruct a base tree...
    M       pom.xml
    .git/rebase-apply/patch:10: trailing whitespace.
        
    .git/rebase-apply/patch:17: trailing whitespace.
            
    warning: 2 lines add whitespace errors.
    Falling back to patching base and 3-way merge...
    Auto-merging pom.xml
    CONFLICT (content): Merge conflict in pom.xml
    error: Failed to merge in the changes.
    Patch failed at 0001 
    The copy of the patch that failed is found in: .git/rebase-apply/patch
    
    When you have resolved this problem, run "git rebase --continue".
    If you prefer to skip this patch, run "git rebase --skip" instead.
    To check out the original branch and stop rebasing, run "git rebase --abort".
    

提交回复
热议问题