28 marca 2011

Github + xCode 4

After 2 days of messing up with xCode 4 I came up with a complete solution on how the Git works inside xCode 4.

First of all, we have to understand two main concepts:
- Local repository (repository that is stored inside your computer)
- Remote repository (repository that is stored online)

As far as I understand, xCode can perform JUST such tasks:
- Work with local repository - make commits (push command)
- Work with remote repository - pull server-saved folders (repositories)

It's a bit weird that it can't make commits to remote repository.

First, make github's account, make repository, follow the GitHub help's steps (1 and 2).
Let's now start making our first project and make it storable online on the remote repository.
  1. Make a new project in xCode
  2. When prompt in choosing the path, select "Create local git repository for this project"
  3. Now you can make changes in your project and commit changes to the LOCAL repository throught Organiser -> Repositories -> YourProjectNameRepo -> YourProjectNameFolder -> Commit
  4. If you wish to make commits to the Remote repository, just go to Terminal, navigate to your Project's main folder and execute: git push origin master
  5. All your LOCAL commits will be sent to REMOTE repository
If you have a friend that would like to continue working on your project or just work with you on it he can use xCode's second feature.
  1. Go to Organiser -> Repositories -> + -> Add repository... -> Type in your GitHub's repository name -> Paste either SSH path or https, both work.
  2. Click Clone
  3. Show xCode where to Download existing repository
  4. Start working on the project, commit as above.
What about .gitignore and .gitconfig?
xCode when making Local repository handles correct .gitignore and .gitconfig, you don't have to mess up with that. Thanks to (buggy) xCode 4.

4 komentarze:

  1. Your choice of words is rather confusing. In git, you don't "commit" to a remote repository, you push. Using the word 'commit' for both is rather confusing.

    OdpowiedzUsuń
  2. You are right, sorry for the mistake. I've fixed it.

    OdpowiedzUsuń
  3. Hi Peter!

    This is very helpful, thanks!
    Wondering if you've seen any posts on self hosting a GIT anywhere?

    On a different noe,t taking an old project from Xcode 3, and making it usable in Xcode 4 GIT isn't exactly clearly working. Had you had experiences with this?

    Just wondering :)

    Thanks,
    Adam

    OdpowiedzUsuń
  4. Hi chinjazz,
    I've never hosted Git myself but will defeniately have to soon. Once I do that, I will surely write a post about it.

    As for xCode3->xCode4 Git compatibility, sorry no experience.

    But I know how to resurrect old xCode 3 (pre 4.2 SDK) to xCode 4. They're not always compatibile but I've found a simple fix on how to make them work.

    OdpowiedzUsuń

Archiwum bloga