Code Management with git on OS-X

Code Management with git on OS-X is a pleasure most of the time. Git is a huge improvement over subversion. Its faster when working over a network connection and once you get used to how it works, it is really quite a bit easier to work with in a team setting. However as with any tool there are a few tips and tricks to learn and remember. I’ll document these here so that when I forget, I know just where to go.

This is another post I’ll keep adding to over time.

Getting started with Git

XCode is the best way to get git installed. On OS-X I think it is generally advisable to install XCode even if you do not plan to do any development with it. Once you have XCode installed then install the command line tools from a terminal with this command:

xcode-select --install

This will include the latest Apple supported git client. You need to keep updating with Xcode and re-authorizing stuff from the command line. You just need to open a terminal and type “git –version” and it will prompt you to accept the terms. If you get odd errors after updating Xcode you probably need to “re-agree” to terms of use/licensing terms.

The next step is to decide where you want to host your git repositories. I’m not going to run thru the pros/cons of thebitbucket web interface for git major hosting providers ( and, but will simply say that I use Bitbucket professionally so its easier to just keep on using it personally/for my LLC. You can, and I suppose I do, use both. is so pervasive that its kinda unavoidable. They are pretty much the same in terms of working with the command line.

Learning Resources

You can start a free trial on and run thru their Essential Training. Atlassian has some decent training here. I’ve gone thru the course and it is pretty good. Codeacademy and Udacity also have git content, but I have not personally read through their stuff.

Git Authentication – SSH is the way to go

Definitely using SSH is the way to go, although you can use a username/password and even cache this in the Keychain. If you are going to be doing a lot of commits with a project constantly entering username/password is a pain – caching limits this, but you still have to deal with things if you update your password(s). Setting up SSH keys means no more of that! Github has great docs on how to set it up with whoever is hosting git for you. I’m using, but the instructions are the same . The SSH keys in your profile under “Bitbucket Settings” for some reason. That’s different from the commercial version where they are managed in your Profile directly.

Since I work with git professionally and personally, I don’t like mixing up those worlds. I use separate accounts, which means I need multiple SSH keys. Here’s an easy post for how to configure multiple SSH keys. I add the email address for the pro/personal to keep track of them.

Command Line vs. Rich Client vs. Web Client

There are definitely pros and cons to each type of client. I tend to use a mixture of Atlassian’s SourceTree and the git command line. The command line is great for quick commits and pushes. SourceTree is pretty nice for pulling down other people’s repos for an inspection or decision to use their code with mine. The website client for bitbucket is pretty nice for pull request reviews or see the branch and merge flow and things like that. Same goes for github I suppose.

SourceTree also has a nice graphical display of git branching and merging. Git branching and mergingThis can be useful for figuring out where something has gone wrong and/or where to move back in time if there is something going wrong in a build. You can get teh same at the command line, but this is one display where a nice graphical client can be helpful.

I did have trouble with SourceTree correctly using my SSH keys on macOS even though terminal and git was working fine. You’ll need to go into SourceTree and add your github account, but also I had to manually add the key to keychain after creating them and then SourceTree would work or I would just get public key denied errors:

ssh-add -K ~/.ssh/id_rsa

Assuming you’re key is named id_rsa. Passwords can also be a pain to keep synchronized between command line and GUI clients. On OS-X you’ll need to flush out password from the Keychain if they are being periodically changed. SourceTree is not smart enough to prompt for an update to a password stored in the Keychain.

Other Random git Tips

  • Don’t ignore .gitignore, commit it!
  • When all seems totally screwed up, read the docs, but in the end you can always just delete the .git directory.
  • Practice – its actually good to use git for everything since that forces you to learn it.
  • Learn git flow and pull requests.
  • In general there isn’t a big difference between github and bitbucket so if you use both you should be ok.

3 Responses

  1. Huan says:

    Decent post beren!

Leave a Reply