我有一个名为v4的git分支,昨天是从主分支(master)创建的。主分支发生了一些更改,我想将这些更改合并到v4分支中。所以,在v4分支上,我尝试从主分支进行rebase操作,但是有一个文件会导致问题:一个只包含版本号的单行文本文件。这个文件是app/views/common/version.txt
,在rebase之前其内容如下:
v1.4-alpha-02
我正在做的事情是:
> git rebase master
First, rewinding head to replay your work on top of it...
Applying: new version, new branch
error: patch failed: app/views/common/version.txt:1
error: app/views/common/version.txt: patch does not apply
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging app/views/common/version.txt
CONFLICT (content): Merge conflict in app/views/common/version.txt
Failed to merge in the changes.
Patch failed at 0001 new version, new branch
When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".
version.txt
现在看起来像这样:
<<<<<<< HEAD:app/views/common/version.txt
v1.4-alpha-02
=======
v1.4-alpha-01
>>>>>>> new version, new branch:app/views/common/version.txt
所以,我整理了一下,现在看起来是这样的:
v1.4-alpha-02
然后我尝试继续:首先我尝试提交:
> git commit -a -m "merged"
# Not currently on any branch.
nothing to commit (working directory clean)
没有找到解决方法。所以,我正在尝试添加这个文件:
git add app/views/common/version.txt
没有回应。我猜没有消息就是好消息。所以,我继续尝试:
> git rebase --continue
Applying: new version, new branch
No changes - did you forget to use 'git add'?
When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".
在这个时候,我已经兜了很多圈子了,头都撞到桌子上了。
这里到底是怎么回事?我哪里做错了吗?有人能给我指点一下吗?
编辑 - 为unutbu
我按照你的建议更改了文件,但仍然遇到了相同的错误:
> git rebase master
First, rewinding head to replay your work on top of it...
Applying: new version, new branch
error: patch failed: app/views/common/version.txt:1
error: app/views/common/version.txt: patch does not apply
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging app/views/common/version.txt
CONFLICT (content): Merge conflict in app/views/common/version.txt
Failed to merge in the changes.
Patch failed at 0001 new version, new branch
When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".
git rebase master
并让它失败_;2)然后编辑version.txt
,使它在那一点上看起来应该是这样,并保存编辑;3)接着你执行git add .../version.txt
;4)然后你执行git rebase --continue
(不要'commit'!) 如果rebase --continue
在这里成功,它已经被提交了(这里不需要git commit
!),所以剩下要做的就是git push
(如果你使用远程仓库)。希望这有帮助,如果我理解得对的话:) - 干杯! - sdaau