GIT:“被我们删除”冲突有多危险?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42174485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
GIT: How dangerous is "deleted by us" conflict?
提问by taras
Few days ago I made new branch "new_branch" based on "master". While I worked on my "new_branch" with file "file.php", second developer on his branch deleted the file "file.php" and merged his branch with "master". Now I need to rebase my branch on current "master". After command git pull --rebase origin master
I have conflict
几天前,我基于“master”创建了新分支“new_branch”。当我使用文件“file.php”处理我的“new_branch”时,他分支上的第二个开发人员删除了文件“file.php”并将他的分支与“master”合并。现在我需要在当前的“master”上重新设置我的分支。命令后git pull --rebase origin master
我有冲突
deleted by us: app/file.php
被我们删除:app/file.php
I don't now what to do, I don't want to lose changes I've made in this file. After commands
我现在不知道该怎么办,我不想丢失我在这个文件中所做的更改。命令后
git add -A
git rebase --continue
file will disappear in my "new_branch"?
文件会在我的“new_branch”中消失吗?
回答by Tim Biegeleisen
The message deleted by us: app/file.php
means precisely what you described, namely that someone deleted this file in the master
branch on which you are rebasing new_branch
.
该消息的deleted by us: app/file.php
含义正是您所描述的,即有人在master
您重新建立基础的分支中删除了此文件new_branch
。
Assuming that the delete has not yet been staged and you want to keep this file, then you should git add
the file to mark it that it should be kept:
假设删除还没有被暂存并且你想保留这个文件,那么你应该git add
将文件标记为它应该保留:
git add app/file.php
Then, resolve all other merge conflicts and do git rebase --continue
然后,解决所有其他合并冲突并执行 git rebase --continue
Note that if you wanted to accept the delete you would do git rm
instead.
请注意,如果您想接受删除,您会这样做git rm
。
回答by sathish kumar
This happens when you are have stashed a file into your feature branch which is not there is your origin branch (master/develop).
当您将一个文件隐藏到您的功能分支中时,就会发生这种情况,而该分支不存在您的原始分支(主/开发)。
git add app/file.php
will solve you the problem.
会解决你的问题。