为什么 rebasing 取消设置我当前的分支并且没有完成?
Why does rebasing unset my current branch and does not complete?
我在分支 b4 上执行“$ git rebase master”,它给我带来了冲突。
$ 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”时,它并没有完成 rebase,而是给了我更多 "instructions"。为什么?
$ 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".
I fixed conflicts and committed the changes:
那是你出错的地方。 git rebase --continue
期望更改在索引中,但尚未提交。由于您已经提交了更改,git rebase
自己的尝试失败了,因为没有要提交的更改。
您应该能够通过 运行 git reset --soft @^
撤消您的提交操作,而无需重置索引。 git rebase --continue
应该在那之后工作。
您也可以使用 git rebase --skip
来绕过 git rebase
自己提交更改的尝试,但这有更多的风险:您自己的提交很可能没有尊重原始提交的作者姓名、电子邮件和时间。
git status
表明您不在任何分支这一事实不是问题。 git rebase
有意从当前分支分离,直到操作完成。这将在操作成功后修复。
我在分支 b4 上执行“$ git rebase master”,它给我带来了冲突。
$ 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”时,它并没有完成 rebase,而是给了我更多 "instructions"。为什么?
$ 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".
I fixed conflicts and committed the changes:
那是你出错的地方。 git rebase --continue
期望更改在索引中,但尚未提交。由于您已经提交了更改,git rebase
自己的尝试失败了,因为没有要提交的更改。
您应该能够通过 运行 git reset --soft @^
撤消您的提交操作,而无需重置索引。 git rebase --continue
应该在那之后工作。
您也可以使用 git rebase --skip
来绕过 git rebase
自己提交更改的尝试,但这有更多的风险:您自己的提交很可能没有尊重原始提交的作者姓名、电子邮件和时间。
git status
表明您不在任何分支这一事实不是问题。 git rebase
有意从当前分支分离,直到操作完成。这将在操作成功后修复。