121

Is there any way to use a git repository with the built in SCM functions of Xcode?

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
Gordon Wilson
  • 26,244
  • 11
  • 57
  • 60

14 Answers14

74

Xcode 4 supports git natively (Developer Tools State of the Union Address at WWDC 2010)

Learn more here: What's new in Xcode 4
The documentation from Apple is lengthy, but a good read.

Hans Ekbrand
  • 405
  • 5
  • 13
TodK
  • 1,079
  • 10
  • 17
73

NOTE: despite all the up-votes, this answer is out of date as of June 2010


There's no git support within Xcode, but that's no reason not to use git for your Xcode projects. I've had good results managing my Xcode projects using the standard git command line or GitX.

Shane Vitarana has a nice set of .gitignore settings to use as a starting point.

Abhi Beckert
  • 32,787
  • 12
  • 83
  • 110
Abie
  • 10,855
  • 6
  • 32
  • 39
39

A nice way to "Integrate" git with Xcode is to use DTerm. You bring up DTerm in a floating window with a key combination. DTerm knows the full path to the current document in the editor.

For Example to run a diff on the file you are editing you:

1) Press Ctrl-Return to bring up the DTerm window. (This key combo is configurable).

2) type 'git diff cmd-shift-V'. That will overwrite the last command when you start typing and insert the name of the current file in the window. Since your working directory is set to the parent directory of the selected file the command is nice and short.

I have no connection at all with Decimus. I am just a satisfied user who has run thousands of commands through DTerm.

Edit: As of 27 August 2009 DTerm is free. If you bought your copy of DTerm, the upgrade to the next version is free, regardless of when you purchased DTerm. See their blog post

Edit 2: DTerm is now available on the Mac App Store. It will be interesting to see if they kept the promise that they made in their blog post.

logancautrell
  • 8,762
  • 3
  • 39
  • 50
Mark
  • 6,108
  • 3
  • 34
  • 49
  • 8
    Mark - you have no idea how happy you have made me. I cannot believe I've been living without DTerm all this time! – Mark Oct 29 '09 at 09:04
  • I ran into a small thing: it is cmd-shift-V rather than ctrl-shift-V. – Courtney Faulkner Mar 15 '10 at 02:48
  • Dterm is **absolutely** amazing!!! -- when it works. It's very buggy with their latest version and 10.6.6 latest. I would kill to have this working right! – Yuji 'Tomita' Tomita Feb 18 '11 at 14:59
  • Try deleting the preferences file. I have had no problems with it. I have been using it for a long time. Is your login using English as the language and character input? – Mark Feb 18 '11 at 15:12
15

In addition to the .gitignore settings referenced from the post above I have added the generated files to my config file.

build/
*.pyc
*~.nib/
*.pbxuser
*.perspective
*.perspectivev3
*.xcworkspace/
xcuserdata/

This helps to keep the noise out of my depot.

If I need to add generated files I add a Release folder and keep the *.framework and *.app folders to my project directory. I add anything I release to the testing group to the Release folder and tag it.

Mark
  • 6,108
  • 3
  • 34
  • 49
10

No, there's not, and to be honest I'm rather grateful, as the SVN support in Xcode seemed really flaky to me. After I moved to Git for my personal projects, I just have a Terminal window open that I can fire off git add and git commit as needed.

logancautrell
  • 8,762
  • 3
  • 39
  • 50
Daniel Hill
  • 429
  • 6
  • 7
4

Xcode doesn't have a public plug-in API, so no, there's no way to directly add support for git to Xcode.

You can, however, create scripts for Xcode's script menu that can perform various git operations.

Chris Hanson
  • 54,380
  • 8
  • 73
  • 102
3

The latest Xcode 4 beta has git integration, however, it does not install it by default, neither does it use your currently installed git.

What I had to do was install the "System Tools" option in the Xcode installer. (Which is skipped by default) after that, the organizer recognized that my project was already under git control, and integrated smoothly.

logancautrell
  • 8,762
  • 3
  • 39
  • 50
jschank
  • 554
  • 1
  • 5
  • 16
3

Well, there is this thing called git-cvsserver that lets git pretend it's CVS. But I don't know the state of affairs concerning that, or CVS support in Xcode.

logancautrell
  • 8,762
  • 3
  • 39
  • 50
Jasper Bekkers
  • 6,711
  • 32
  • 46
3

I don't believe there's a way to provide plug-in support for Xcode. So, until Apple warms up to git, we'll be stuck with 3rd party tools and the command line. Not that that's a bad thing...

Chris Stewart
  • 3,303
  • 9
  • 36
  • 55
2

With Xcode 4 if you want to use your own version of Git you can create a symlink from /usr/bin/git to wherever you have installed your Git binary

Robert Conn
  • 877
  • 8
  • 17
1

You can use Xcode with Git repos. Visual Studio Team Services offers free, private, and unlimited Git repos in the cloud. Not only can you use Xcode, but also Eclipse, Visual Studio, Team Services' own web browser interface, or any other editor/IDE you like. Share code with the first 5 users for free too.

YouTube video: https://youtu.be/S83kn0i4WYs

Esther Fan - MSFT
  • 8,276
  • 4
  • 27
  • 25
1

With the latest Xcode 4.1 it's definitely possible and everything you need is installed by default.

I wrote a blog post just about this very topic:

Xcode iPhone beginner projects with GitHub integration

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
0

I am wondering, if a wrapper can be done using Xcode scripting features ? check : http://www.cimgf.com/category/version-control/git/

BTW, if Xcode can not do the job, eclipse can do the job but it may lack Cocoa api etc ...

logancautrell
  • 8,762
  • 3
  • 39
  • 50
RzR
  • 3,068
  • 29
  • 26
0

I use external editors anyway. Many of them support git commands. In this way, git is "integrated" into Xcode