15. Presentation tackmobile.com
Do I Have The Latest Changes?
• git fetch - git must have the latest changes
locally to tell you
• git log develop..origin/develop
• If no commits - yes, you have the latest
• Tools like SourceTree will often do automatic
fetches
17. Presentation tackmobile.com
What’s Upstream?
• Upstream is the repository/branch from which
changes come
• ➜ git status
# On branch develop
# Your branch is behind 'origin/develop' by 2
commits, and can be fast-forwarded.
# (use "git pull" to update your local branch)
#
nothing to commit, working directory clean
19. Presentation tackmobile.com
Checking All Branches
• ➜ git branch -lvv
* develop 24c4398 [origin/develop: behind 2]
warning fixed.
master 3cc12bb [origin/master: behind 3]
Giving username an email keyboard for what seems to be the
common use case.
• Add -a to include remotes
20. Presentation tackmobile.com
Is This Branch Merged?
• Which branches contain a given commit?
• git branch --contains <branch/commit>
• ➜ git branch --contains develop
* develop
• ➜ git branch --contains master
* develop
master
21. Presentation tackmobile.com
Where Did This Bug Come From?
• git bisect!
• Known Good Commit <|> Latest Buggy Commit
• build and run
• mark a commit good or bad
• git walks forward or backward
• repeat
25. Presentation tackmobile.com
ssh
• git clone ssh://user@host/path/.git
• Push to origin
• Pull from origin
• Use when just starting out a private project?
27. Presentation tackmobile.com
Submodules
• A git repository tracked as part of the tree of
another repository
• Git (kind of) manages it
• cd in -> get another git repo
• Sort of a broken SVN external (the only thing I
like better about SVN than git)
29. Presentation tackmobile.com
Submodules: Why do they suck?
• You have to be explicit about them; git won’t
manage them for you
• Devs on your team need to be educated
• Have to jump through hoops to connect the
repo back to its origin
• Hard to share local changes
30. Presentation tackmobile.com
Working with Submodules
• git submodule add <repo> <local name>
• .gitmodules
• Keeps submodule at a explicit commit
• ignore = dirty
• git submodule deinit, git rm
31. Presentation tackmobile.com
Submodules: Workflow
• If you need to move the submodule’s commit
• cd to submodule
• move to the new commit
• cd to parent
• git add and commit
• When you pull, add:
git submodule update —install —recursive
36. Presentation tackmobile.com
Git Flow
• Conventions to follow
• Tools to help you follow conventions
• http://nvie.com/posts/a-successful-git-
branching-model/
37. Presentation tackmobile.com
Git Flow Conventions: Master Branch
• The master branch is what is publicly available
now
• You don’t commit directly to master
38. Presentation tackmobile.com
Git Flow Conventions: Develop Branch
• A branch called “develop” is what will become
the next version
• Day to day work happens on develop
• “Integration branch”
39. Presentation tackmobile.com
Git Flow Conventions: Feature Branches
• Long running development go on feature
branches: “feature/foo”
• Long running: “more than one commit”
• Can be pushed to the server and shared
• Branch from develop
40. Presentation tackmobile.com
Git Flow Conventions: Hotfixes
• OMG Problems in Production, create a hotfix:
“hotfix/foo”
• Branch from master (not develop)
41. Presentation tackmobile.com
Git Flow Conventions: Releases
• When a release is almost ready on develop,
create a release branch: “release/2.0.4”
• Branch from develop
• Develop continues on for the next release
• Small changes to release go on release branch
42. Presentation tackmobile.com
Branch Lifecycle
• Features
• Start from develop
• Finished and merged to develop
• Releases
• Start from develop
• Finished and merged to master and develop
45. Presentation tackmobile.com
The Take Home
• You know your way around .git
• You can customize and configure git
• You understand submodules and where they
work (and don’t work)
• You know how git flow can help when releasing
apps with a team
46. Thank you!
Working with Git for the Android Developer • Tony Hillerson
• Questions?
• We’re Hiring! careers@tackmobile.com
• Excellent Team
• Awesome Projects
• Great Office