1

I am using git for the first time, and based on advice from others, I have started using it from the command line rather than from within xcode. After initially committing my project folder, I saw that several files were automatically excluded, including the .xcodeproj file. I added that file and received this error:

E325: ATTENTION
Found a swap file by the name ".git/.COMMIT_EDITMSG.swp"
...
       process ID: 8453 (still running)
While opening file ".git/COMMIT_EDITMSG"
            dated: Thu Dec  8 08:21:00 2011
     NEWER than swap file!

(1) Another program may be editing the same file.
   If this is the case, be careful not to end up with two
   different instances of the same file when making changes.
   Quit, or continue with caution.

(2) An edit session for this file crashed.
   If this is the case, use ":recover" or "vim -r .git/COMMIT_EDITMSG"
   to recover the changes (see ":help recovery").
   If you did this already, delete the swap file ".git/.COMMIT_EDITMSG.swp"
   to avoid this message.

Swap file ".git/.COMMIT_EDITMSG.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: 

I don't know what all this means, but this occurs when Xcode is running and when it is not running, so the part about another program editing the file seems to not be the problem.

As I thought about this, I began to wonder how do I manage the archiving of the project configuration when I am branching? If I don't archive the project file, I imagine that the branches are all using a single project file. This doesn't seem right. So my question is how do I manage the configuration for branches?

Jim
  • 5,940
  • 9
  • 44
  • 91

2 Answers2

4

You should add the .xcodeproj directory and put these entries in your .gitignore:

*.xcuserstate
project.xcworkspace/
xcuserdata/
rob mayoff
  • 375,296
  • 67
  • 796
  • 848
  • This looks like good advice, but I'll have to give Kevin the checkmark. Thanks. +1. – Jim Dec 09 '11 at 01:53
2

That error is being reported by vim, which I assume is your editor. It indicates that vim believes that another copy of vim is already running and editing the file .git/.COMMIT_EDITMSG (which is the file that git uses to prepare the commit message when you're making a commit). It's possible that killing vim while it's editing this file would leave the swap file behind, causing this issue. It's also possible that you really do have another instance of vim running, editing this file. If it's the former, you can either "(R)ecover", which reads the swap file and uses that to populate the editor or "(E)dit anyway", which ignores the swap file. If you do have another copy of vim running then you should probably "(Q)uit" or "(A)bort" to cancel out of this instance of vim.

As for "archiving" the project file (which I assume means tracking in git), you absolutely should have it tracked. And once it's tracked, then each branch will have its own copy, which is right and proper.

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347