Standardize Git branching in mobile development

Quang Nguyen
AndroidPub
Published in
3 min readMay 6, 2017

--

a cute git logo

In our software engineer life, the most important tools as I think are not newest and trending ones. Instead, they are our daily and basic tools, and mastering them is a nontrivial task. One of these tools is Git. We know and use it everyday but not all of us understand it clearly and know how to use it correctly.

All of our daily workflows should be standardized because it ensures the workflow inputs and outputs to be consistent every time. Besides, it saves our time and our brain’s memory which will be allocated to new awesome things but not repetitive and boring ones.

Following a standard Git branching will free you from conflicts s and give you a really smooth releasing flow. Below is just a really small and old thing about Git branching model that I write down to remind myself and hope it helps others. It completely follows Vincent Driessen’s Model which can be applied for general software development. In this post, some detailed steps are added for mobile developers.

Firstly, assume that you app is in development stage or has been released several version. We have two main branches( master and develop) currently.

How to start a new version

  • Checkout develop branch:
    $ git checkout develop
  • Change configuration to debug mode if needed. (i.e: app name, id, host url, etc).
  • Create new feature-x or fix-bug-x branch from 'develop':
    $ git checkout -b feature-x develop
  • When complete that new feature or bug fix, merge its branch back to develop branch and delete it. i.e:
    $ git merge --no-ff feature-x
    $ git branch -d feature-x

How to release a new version

When all next version’s features are completed and codes are ready for new release.

  • Make sure all of feature branches are merged into develop branch.
  • Create new release-x branch. i.e:
    $ git checkout -b release-1.1.0 develop
  • Change configuration to release mode if needed. (i.e: app name, id, host url, etc).
  • Increase version name and build number (in General Project Setting for iOS, in app’s build.gradle for Android).
  • Update ‘CHANGELOG’.
  • Create new commit: $ git commit -a -m "Prepare version 1.1.0"
  • Merge release-x branch to master branch and tag new release.
    $ git checkout master
    $ git merge --no-ff release-1.1.0
  • Solve conflicts(if any) and commit.
    $ git tag -a v1.1.0
    $ git push
    $ git push --tags
  • Build and publish on store:
    - iOS: Build, archive, validate and upload new archive to App Store.
    - Android: Build, generate signed APK and upload to Google Play.
  • Merge release-x branch to develop.
    $ git checkout develop
    $ git merge --no-ff release-1.1
  • Solve conflicts(if any) and commit.
    $ git push
    $ git push --tags
  • Delete release-x branch.
    $ git branch -d release-1.1

Besides, I record the above flow in a Github repository which will keep the best practices and standard things about Android and iOS native development.

Hope that the above small thing can improve our daily work in mobile developer life.

If you are interested in my new useful blog posts and projects, you can subscribe to my newsletter by clicking the below link. Thanks.

SUBSCRIBE TO USEFUL BLOG POSTS AND COOL PROJECTS.

Or please get in touch with me via Github, Twitter, Facebook, or LinkedIn. Happy coding and have a good time!

--

--