Using SourceTree on the Mac with github

Screen Shot 2015-02-19 at 4.40.17 PM

I’m using github for a large project with multiple developers – there have been a few wrinkles using the github mac client so we switched to SourceTree – a free github client. We’re using it to implement gitflow – I’ve been very happy with it so far – below is our process…


Before you start a new feature

  • make sure you have the latest copy of the dev branch (do a fetch on remote, then pull if dev branch shows any changes)
  • use gitflow command ‘new feature’ and name it
  • make your changes to code
  • stage files, then commit and push all changes to your feature branch
  • before finishing feature (merging with development) – use fetch to check status of development branch,
    • if there have been commits by other members of the team since you downloaded the development branch you will need to merge those changes to your feature branch before finishing the feature
      • checkout the development branch, then pull it to get current
      • re-checkout your new feature branch
      • use gitflow ‘finish current’ (set to ‘delete branch’ and ‘force delete’)
      • merge conflict message, go to working copy, right click resolve conflicts – launch external merge tool, choose resolution, file save merge, quit merge tool (do not quit merge tool until you’re done with all merges
      • commit and push merge results
      • now push the new dev branch
    • if there are no merge issues then just push the new dev branch up to the remote origin
  • push develop changes up to remote (if not done already)
  • check github site to confirm your changes are present (just until you are comfortable with this process)

Using XCode 4 with GitHub

Git is a distributed source control system (like subversion) – still not sure what it is and if you need it? Take a look at this crash course.

GitHub is a web-based hosting service for software development projects that use the Git revision control system. GitHub offers both commercial plans and free accounts for open source projects.

This is how we set up Xcode 4 and GitHub to work together on the Mac for a new iOS (iPhone or iPad) project. We’re assuming Mac OS Version 10.6.8, Xcode version 4.02 and the latest version of Git.

  1. Register as a new user with GitHub. You can host public open source projects on GitHub for free – if you need private projects you will have to sign up for a paid plan.
  2. Follow GitHub set up steps 1 & 2.
  3. Create your new project in Xcode – check ‘create local git repository for this project’ within the wizard when asked.
  4. Create a README file and add it to the main directory of your Xcode 4 project.
  5. On GitHub create a new repository with the same name as your Xcode project (it doesn’t have to be same name but keeps things simpler).
  6. After creating the new repository (or ‘repo’) on GitHub – follow the ‘Existing Git Repo?’ directions on GitHub.
  7. Now as you make changes in your Xcode source code or project – you can commit them with the standard Xcode command – File -> Source Control -> Commit.
  8. After committing your changes you can push them to your remote repository on GitHub from the command line (from your Xcode project directory) using ‘git push -u origin master’.