[英]How to leave the temporal branch created by “git pull --rebase”?
While being in a branch I have executed 在分支中时,我执行了
git pull --rebase origin master
This have been resulted in some merge conflicts. 这导致了一些合并冲突。 By opening the files and selecting the needed parts of the code I have resolved the conflicts.
通过打开文件并选择所需的代码部分,我解决了冲突。 Then I have executed
git add
and git commit
. 然后我执行了
git add
和git commit
。
Now, when I execute, git branch
, I see that I am not in the original branch but in a branch named: 现在,当我执行
git branch
,我看到我不在原始分支中,而是在一个名为:
(no branch, rebasing my_branch_name)
The git status
tells: git status
告诉:
rebase in progress; onto 5ae1f3d58
You are currently rebasing branch 'my_branch_name' on '7af1d3d38'.
(all conflicts fixed: run "git rebase --continue")
nothing to commit, working tree clean
However, when I execute git rebase --continue
, as suggested, nothing changes. 但是,当我按照建议执行
git rebase --continue
,没有任何变化。 I stills stay in this strange temporal branch. 我仍然呆在这个奇怪的时间分支中。 So, how can I go back to my branch and keep changes introduced by the
git pull --rebase
and the manual merge? 那么,如何才能回到分支并保留
git pull --rebase
和手动合并引入的更改?
On rebase
, the conflict will be listed. 在
rebase
,将列出冲突。 You need to solve the conflicts in each file. 您需要解决每个文件中的冲突。
Find the conflicted files. 查找冲突的文件。
conflict will look like this 冲突看起来像这样
<<<<<<< HEAD
code from master branch
>>>>>>>>>>>>>>
<<<<<<<<< <some_commit_id>
code from your local file
>>>>>>>>>>>>>>>>>>>>>>>`
Edit that part and keep the code you actually want. 编辑该部分并保留您实际想要的代码。
Then in terminal add the files to git using 然后在终端中使用以下命令将文件添加到git中
git add <file_name>
After all conflicts get resolved and added to git 解决所有冲突后,将其添加到git中
run git rebase --continue
运行
git rebase --continue
If you don't want to do any of this and wants old code before rebase, simply run git rebase --abort
如果您不想执行任何操作,并且想要在
git rebase --abort
之前使用旧代码,只需运行git rebase --abort
When resolving conflicts in rebase you do not need to run git commit
before git rebase --continue
, this is probably the cause of the issue 解决rebase中的冲突时,无需在
git rebase --continue
之前运行git commit
,这可能是问题的原因
If you do then git commit --rebase
will try to commit the change and get confused as nothing has changed. 如果您这样做了,那么
git commit --rebase
将尝试提交更改并由于没有任何更改而感到困惑。
The easiest option is probably to undo the last commit and then continue 最简单的选择可能是撤消上一次提交,然后继续
git reset HEAD^
git rebase --continue
If you ever get too deep into a rebase that goes wrong you can also git rebase --abort
and try starting over. 如果您对发生错误的rebase过于深入,也可以
git rebase --abort
并尝试重新开始。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.