SlateEntropy
SlateEntropy

Reputation: 4018

Pushing git repository to Xcode

Current setup:

Home iMac with Xcode project and hosting the git repository. MacBook for working away from home with project cloned through Xcode.

I am able to pull changes made on my iMac to the MacBook without a problem, its sending the changes I make on my MacBook back to the iMac which I'm having trouble with.

I make my edits and File > Source Control > Commit which works without error and File > Source Control > Push the files - no problem.

But, on my iMac I can't get to the edits, as soon as Xcode launches, the 'M' appears next to the edited files showing a change has been made (the one on my MacBook) and I cannot revert the change, the only thing I can do is commit the unedited file and 'revert' it.

Upvotes: 1

Views: 344

Answers (1)

Greg Hewgill
Greg Hewgill

Reputation: 993085

You are doing a "push" operation to a non-bare repository - something that is specifically recommended against in the Git documentation.

What happens is the push operation updates the repository behind the scenes, but not your working directory. So Git sees all the files changed on your laptop as "changed" back to their original state on the iMac. You can fix this, if you are absolutely sure that you do not have uncommitted work on the iMac, by doing a git reset --hard master (or whatever your branch name is).

A better solution is to create another repository on the iMac, that is a "bare" repository, which you will treat as your shared global repository. Each working directory would both pull from and push to the global repository, avoiding this problem.

Upvotes: 2

Related Questions