4

My friend and I are trying to work on an iPhone project, but have a problem with version conflict management using github.

Example: Both of us are working on a certain line of code with xCode 4.2 (and the github mac client)

int majorVersion = 0;

1) He changes the code to int majorVersion = 999; commits changes; syncs - no problems, will end up in github

2) Simultaneously, I change the code to int majorVersion = 666; then:

  • I commit changes
  • conflict - I choose my certain version by selecting line of code (int majorVersion = 666;)
  • in xCode, I delete the funny <<<<<< HEAD bits (so that only int majorVersion = 666; remains)
  • commit changes
  • finally: I try to Publish branch but get the following error:

error: unable to push to unqualified destination: HEAD The destination refspec neither matches an existing ref on the remote nor begins with refs/, and we are unable to guess a prefix based on the source ref. error: failed to push some refs to 'https://github.com/XXX/XXX.git'

What are we doing wrong? Is the main problem that I have deleted the funny <<<<< and the HEAD declaration in xCode (see screenshot below)? How are we supposed to handle such conflicts?

enter image description here

n.evermind
  • 11,944
  • 19
  • 78
  • 122
  • Use the command line `git` program. What does `git status` say? Did you commit your merge conflict resolution before trying to push? – Daenyth Nov 29 '11 at 21:31
  • @Daenyth: Yes, I tried to commit my merge conflict resolution before trying to push. Committing was not a problem. Pushing prompted the error. git status will log this to console: # Not currently on any branch. nothing to commit (working directory clean) – n.evermind Nov 29 '11 at 21:57
  • Part of your issue is that you're using the GitHub Mac client. It looks nice, but doesn't really show branch structure very well. Try SourceTree or GitX for a better visualization of your repo. – Marnen Laibow-Koser Jan 20 '18 at 02:52

1 Answers1

1

Not currently on any branch. nothing to commit (working directory clean)
(as seen in this example)

That means you are in a DETACHED HEAD, and resolutions (git log, git reflog, ...) are mentioned in "Not currently on any branch + git commit + checkout when not in any branch. Did i loose my changes?".

The problem isn't the concurrent modification in itself, but rather how you did checkout your code in XCode4 in the first place: any checkout of a tag or a SHA1 would result in a detached head situation.

See also the resolution proposed in "Git Checkout reverted code to older commit, how to revert back?".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for suggesting how to resolve the problem. However, I don't understand how I should have handled the situation in the first place. Instead of deleting the +<<<<<<<<<< and +=========== what exactly do I have to do? – n.evermind Nov 30 '11 at 08:45
  • 1
    No the delete part if good (it is how you solve a conflict). But before even starting making any modification (which or without conflict), you first need to be sure you have checked out a branch, and not a SHA1 or a tag. Otherwise you will have an issue when trying to commit. – VonC Nov 30 '11 at 08:58
  • Thanks a lot. We will give this another try and the one who has the conflict will make sure to check out the branch before committing. – n.evermind Nov 30 '11 at 09:16