git

I had a confused start to using git, since it doesn’t use enough common language with Subversion or TFS. Clone, push, pull, these are all new terms in this domain.

Setting up git on a new Mac

  1. Terminal: git config --global user.name "John Hancock"
  2. Terminal: git config --global user.email "jhancock@mac.com"
  3. Terminal: git config --global credential.helper osxkeychain
  4. XCode: XCode ▸ Preferences… ▸ Accounts: Add a repository if you don’t have one. If you’re using Atlassian BitBucket, it will look something like this: https://jhancock@bitbucket.org/hancockaccount/repository.git

Git calls everything a repository, whereas TFS, for instance, calls the server’s files a repository and the local files a workspace.

Now, you either need to get a project that’s already on the remote repository, or you need to import files to a local repository and push those to the remote repository.

Get existing files

https://jhancock@bitbucket.org/hancockaccount/repository.git

Recover from fukked up git

Exit XCode

In Terminal

  1. CD to project root
  2. rm -rf .git

In BitBucket

  1. Delete the bad repository.

Create a repository from existing local files

In BitBucket

  1. Create a new repository.

In a plaintext editor (such as SubEthaEdit)

In the project root create .gitignore with these lines:

build/
xcuserdata/
*.xcuserstate

In XCode

  1. Source Control ▸ Create working copy
  2. Source Control ▸ PROJECT ▸ Configure PROJECT
  3. Remotes ▸ +
  4. Name: origin
  5. Address: https://USERNAME@bitbucket.org/TEAM/REPO.git
  6. Source Control  Push