1

I've lost more work as a result of failing to understand git than I have any other way. I'm now in the familiar position of being presented with a two-option warning from Xcode, which has come about as a result of my switching to a different branch in git (I did the switch at the command line - I don't use Xcode's built-in vc support). The last time I was here I guessed wrong and lost work. This time I'd like to understand what the two choices mean. Here's what I did:

// On branch master
$ git checkout images_sidebar

Here's what I got:

enter image description here

All I want to do is have Xcode present me with the project as it was when I last commited on the branch that I'm switching to.

Paul Patterson
  • 6,840
  • 3
  • 42
  • 56
  • If you want Xcode to present you with the project as it is on `images_sidebar`, then just click "Revert". However, keep in mind that if you have any changes to your workspace in Xcode that *have not been saved to disk*, Xcode will discard them when it reverts. – Craig Otis Aug 21 '14 at 14:30
  • Possible duplicate of [Difference between "Keep Xcode Version" vs. "Use Version on Disk"?](https://stackoverflow.com/questions/67192161/difference-between-keep-xcode-version-vs-use-version-on-disk) – pkamb Oct 11 '21 at 22:16

1 Answers1

3

If I'm not mistaken, here's the scenario of your situation:
1. You are on the branch named branch1
2. You open the project with Xcode
3. While the project is opened, you checkout branch2

So Xcode remains branch1's .xcworkspace file but you have checked out branch2 so the .xcworkspace file on the disk has changed.

Here, Xcode detects that change and asks you to open this changed file or remain with the current (which will cause to override branch2's .xcworkspace file).

If you want to open the files of the branch you are switching to, then you should go with the Revert option.

There is one thing that I mostly realise by experiencing is that Xcode works a little bit dirty, like most of the other IDEs. So, you have to remain a well organised .gitignore file in your repository. I personally recommend to take a look at the schemes here: Git ignore file for Xcode projects

It won't actually affect your situation if you are just checking out between branches but when you merge with other branches, Xcode's specific files might get overridden as well and you should take care of that.

Community
  • 1
  • 1
kubilay
  • 5,047
  • 7
  • 48
  • 66