git GITHUB 冲突解决
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13210706/
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
GITHUB Conflict Resolving
提问by Murali Murugesan
I am a newbie for github and started using GITHUB for WINDOWSchosen private repositories and shared the same with my colleagues.
我是 github 的新手,开始将GITHUB 用于 WINDOWS选择的私有存储库,并与我的同事共享。
Now we are experiencing a problem, not sure how to solve it. We tried google and no use.
现在我们遇到了一个问题,不知道如何解决。我们试过谷歌,没有用。
Myself and a colleague worked on a same file at a same time, he committed before me. I like to know the changes he made and I want to merge his change with my local file and finally want to commit my version. Is it possible with GITHUB using GITHUB for windows? I have done the same before with Tortoise SVN
我自己和一个同事同时处理同一个文件,他在我之前提交。我想知道他所做的更改,我想将他的更改与我的本地文件合并,最后想提交我的版本。GITHUB 是否可以在 Windows 上使用 GITHUB?我以前用 Tortoise SVN 做过同样的事情
I Opened shell command prompt and tried something like
我打开了 shell 命令提示符并尝试了类似的东西
$ git diff
But it shows only differences and not advised me to merge local with staged version ..
但它只显示差异,不建议我将本地版本与暂存版本合并..
回答by Simon Boudrias
If you press the sync
button, you'll be pulling changes your friends made and pushed online. If changes don't merge cleanly, you'll be prompt that a conflict occurred. This will add conflicts line into your files where you'll have to go and resolve them. After that, you'll only need to commit the changes.
如果您按下sync
按钮,您将拉取您的朋友在网上所做和推送的更改。如果更改没有完全合并,则会提示您发生了冲突。这会将冲突行添加到您的文件中,您必须在其中解决它们。之后,您只需要提交更改。
The conflicted lines should appear in the Github for Windows interface (although I'm not 100% sure, I actually prefer resolving conflict through the command line).
冲突的行应该出现在 Github for Windows 界面中(虽然我不是 100% 确定,但我实际上更喜欢通过命令行解决冲突)。
By command line, you'll have to enter command as so:
通过命令行,您必须像这样输入命令:
git pull
# If merge conflict, you'll be prompt to resolve them, git will list conflicted files
# Open those files in you editor and resolve conflicts. Line will be marked in the files.
# When all is resolved :
git add -A
git commit
# No need to enter a message, git will automatically fill the message with
# merge conflict specific information
git push
In your files, the conflict marker will look something like this:
在您的文件中,冲突标记将如下所示:
<<<<<<<<<<< [sha-1 of the commit]
function() {
==================
function( hey ) {
HEAD>>>>>>>>>>>>>
回答by aliteralmind
In my case, it just turned out that I neglected to sync a previous commit before attempting to sync the next one.
就我而言,结果是我在尝试同步下一个提交之前忽略了同步前一个提交。
No conflict resolution necessary.
无需解决冲突。
I also found it interesting that all the difference blocks
我还发现所有差异块都很有趣
<<<<<<<<<<<<<<<<<...
...
======================
...
HEAD>>>>>>>>>>>>>>
are actually placed into your source code. Just open the conflicted file in a text editor and keep/delete the desired branch.
实际上被放入你的源代码中。只需在文本编辑器中打开冲突文件并保留/删除所需的分支。