Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git for iOS Developers

Git for iOS Developers

First given at iOS Dev UK, Aberystwyth, 2013

Simon Whitaker

September 02, 2013
Tweet

More Decks by Simon Whitaker

Other Decks in Technology

Transcript

  1. // TODO • Enhance your daily Git skills • Learn

    some tips for coping with diff and merge problems • Look at some workflow options for small teams • If we have time, some lulz
  2. Git in Xcode • Basic git support • Check out

    • Commit • Branch • Push/Pull
  3. Specifying revisions git checkout master git checkout v1.2 git checkout

    6a54bc0 git checkout master@{yesterday} git checkout master@{2 hours ago}
  4. git bisect • Binary search for bugs • Give it

    a “good” and “bad” ref, it’ll pick a commit half way between the two for you to test • Test, mark it good or bad, repeat
  5. $ git bisect start $ git bisect good @{yesterday} $

    git bisect bad Bisecting: 14 revisions left to test after this (roughly 4 steps) [368c20e61b675494d6274afe6c6ddfb9 30f3e290] Make awesome change to teh codez
  6. $ git bisect bad Bisecting: 6 revisions left to test

    after this (roughly 3 steps) [8c20e61b675494d6274afe6c6ddfb930 f3e29036] Added new design assets
  7. Automating git bisect $ git bisect start $ git bisect

    good @{3 days ago} $ git bisect bad $ git bisect run command args
  8. $ git bisect start $ git bisect bad $ git

    bisect good @{yesterday} $ git bisect run xctool clean test Who broke the tests? facebook/xctool
  9. Add git commands • Write a script, save it somewhere

    • Make it executable • Add entry to [alias] section of ~/.gitconfig
  10. Example: release notes $ git release-notes 1.1 - Add new

    app icon - Fix Facebook SDK issue - Add Korean localization simonwhitaker/dotfiles
  11. Example: is ancestor $ git is-ancestor ba6d524 827dd3a ba6d524 is

    an ancestor of 827dd3a simonwhitaker/dotfiles
  12. hub $ brew install hub $ alias git=hub $ git

    clone user/project [ Clones git://github.com/user/project.git ] $ git create [ Creates repo on GitHub, sets remote ] github/hub
  13. version.sh • Set the version number of a build at

    build time, based on git tags • http://stuff.bondo.net/post/7769890357/ using-build-and-version-numbers-and-the- art-of gist.github.com/osteslag/1089407
  14. .strings files • Unicode text, stored as UTF-16 • Use

    a third-party diffing tool • Vimdiff: git difftool -t vimdiff • Kaleidoscope: git difftool -t ksdiff • Store as UTF-8
  15. .pbxproj, .xcdatamodel • Google “git merge pbxproj” • http://stackoverflow.com/questions/2729109/ •

    “Should I merge .pbxproj files with git using merge=union [in .gitattributes]?”
  16. No

  17. .xib • Can merge in Xcode 5! (Thanks, iOS Dev

    Weekly) • http://nilsou.com/blog/2013/08/07/xcode-5- finally-makes-interface-builder-a-viable- option-for-teams/
  18. Everything on master • Fine if you’re a sole developer

    • Still worth using branches for experimental stuff • Don’t forget, it’s easy to branch retrospectively
  19. git-flow • master, develop, feature & release branches • CLI

    tool hides the complexity • Fine if you have a periodic release cycle • In small teams, often better to have a formal process than an informal one nvie/gitflow
  20. GitHub Flow • What GitHub do • master is always

    deployable • Develop on a branch, merge to master via pull request then immediately deploy • Great for web-based stuff like GitHub • Do clients want a new adhoc build after every feature?