GITHUB Conflict Resolving
Asked Answered
W

2

16

I am a newbie for github and started using GITHUB for WINDOWS chosen private repositories and shared the same with my colleagues.

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

I Opened shell command prompt and tried something like

  $ git diff

But it shows only differences and not advised me to merge local with staged version ..

Witness answered 3/11, 2012 at 15:42 Comment(0)
I
19

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.

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).

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>>>>>>>>>>>>>
Inland answered 3/11, 2012 at 15:51 Comment(2)
For this situation, I'd suggest git add -u rather then git add -A (or better, git commit -a). There is only one file of interest that appears to already be in the repository.Cascade
You are my hero. Why couldn't I find this anywhere online!Trella
O
1

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.

Oilstone answered 14/7, 2014 at 22:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.