2015-06-14 82 views
0

我在分支b4上做「$ git rebase master」,它給了我衝突。爲什麼rebasing未設置當前分支並未完成?

$ git rebase master 
    First, rewinding head to replay your work on top of it... 
    Applying: rebase: Modified 1.txt 
    Using index info to reconstruct a base tree... 
    M  1.txt 
    Falling back to patching base and 3-way merge... 
    Auto-merging 1.txt 
    CONFLICT (content): Merge conflict in 1.txt 
    Failed to merge in the changes. 
    Patch failed at 0001 rebase: Modified 1.txt 
    The copy of the patch that failed is found in: 
     c:/hands_on/github/learn_git/cmd/.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". 

在這裏,它顯示我不再在分支b4上。

$ git status 
    # Not currently on any branch. 
    # You are currently rebasing. 
    # (fix conflicts and then run "git rebase --continue") 
    # (use "git rebase --skip" to skip this patch) 
    # (use "git rebase --abort" to check out the original branch) 
    # 
    # Unmerged paths: 
    # (use "git reset HEAD <file>..." to unstage) 
    # (use "git add <file>..." to mark resolution) 
    # 
    #  both modified:  1.txt 
    # 
    no changes added to commit (use "git add" and/or "git commit -a") 

我固定的衝突,並承諾改變:

$ vim 1.txt 

$ git commit -a -m "Fixed rebase conflict" 
[detached HEAD 2cb2672] Fixed rebase conflict 
1 file changed, 1 insertion(+) 

$ git status 
# Not currently on any branch. 
# You are currently rebasing. 
# (all conflicts fixed: run "git rebase --continue") 
# 
nothing to commit, working directory clean 

但是,當我嘗試「--continue」,它沒有完整的底墊,而是給了我更多的「指令」。爲什麼?

$ git rebase --continue 
Applying: rebase: Modified 1.txt 
No changes - did you forget to use 'git add'? 
If there is nothing left to stage, chances are that something else 
already introduced the same changes; you might want to skip this 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". 

回答

2

我固定的衝突,並承諾改變:

這就是你出了問題。 git rebase --continue預計這些更改將位於索引中,但尚未提交。由於您已經提交了更改,因此git rebase自己的嘗試失敗,因爲沒有任何更改需要執行。

您應該能夠通過運行git reset --soft @^來撤消您的提交操作,而無需重置索引。在此之後應該可以使用git rebase --continue

你也可以使用git rebase --skip繞過git rebase自己的嘗試來提交更改,但是這樣做可能會有更多的混亂:你自己的提交很可能不會尊重原始提交的作者姓名,電子郵件和時間。

git status顯示您不在任何分支上的事實不是問題。 git rebase故意從當前分支分離,直到操作結束。操作成功後,這將被修復。