Git + GitHub + = Like!

I remember the first time I tried git, just over 2 years ago and just couldn’t get my head round it. So I gave it up and started using subversion which I really enjoyed. Since then I have move onto pastures new and earlier this year started looking into git and GitHub again after seeing the masses of great open source work going on there. So I endeavoured to try again. I found I enjoyed it. Then I introduced it to my workplace and they started to use it and enjoy it to. This post is a collection of best practices, tips and tricks I have found from my use and are a personal opinion only. If you have specific questions following on from this, please comment below or ask me on twitter @pbattisson.

  1. Forget what you know about source control and start learning again. Git is distributed and as such is quite wildly different. It will take some getting you head around the idea of everybody having a repository that is a full system instead of checking in and out, but stick with it.
  2. Use GitHub, they are cheap, they have a fantastic help section, they make coding social and they also help make using git a bit easier.
  3. Use the command line. It will help you understand more accurately what is going on, it is the fastest way to use git and it gives you the most control. And if you are a developer and are not comfortable with a command line then you should be!
  4. Learn how to branch and merge properly - this will help you to really start cooking on gas and make your development effort simple as well as highlighting git’s flexibility.
  5. With development in a team, use branching and work in your own org. Sharing an org and trying to manage the source control process becomes more difficult. You can easily merge across other peoples changes.
  6. In a project, make sure you create you repository in the eclipse project folder. Ignore the .settings folder and you should be good to go.
  7. If you do the above, to start working on a project you just clone/fork it into your Eclipse workspace, create a new project with the name of the repo, select none for the initial metadata download and then save all the information upto the server. Easy!
  8. Commit regularly! Push often!
  9. You should per user story or feature you are working on. If multiple people are on a feature, either share an org (for a couple of people) or split the feature into smaller chunks. This will help your code. Remember that a branch is not a separate directory or folder.
  10. All the items you can see in Eclipse are stored in text based metadata files. When merging and fixing conflicts, it is easiest to open the offending file in Notepad++ on Windows or TextMate on Mac. You can see the errors in the merge tags and resolve them from there.

There are a few things I think could be improved though. GitHub recognition for Apex and VisualForce in their code highlighting (I know linguist is open sourced but I can’t say I know where to begin with it) would be a nice start. The Eclipse git plugin needs work (as does the IDE itself…) in order to make it easier to work with.

On a side note, I am looking into testing out Jenkins and Stratosource as continuous integration and build systems with GitHub. Anybody got any tricks or tips? I will post something up when I do get one of them running.

Share on Twitter, Facebook, Google+
Prev Next