Skip to main content

Create your first commit

This section will give you a practical A-Z guide to follow when creating task branches and merging them into master.

  1. Make sure you have the latest version of master.
git checkout master && git pull origin master
  1. Create your task branch from master. Name the branch as discussed in Intro - Git workflow.
git checkout -b <your-name-space>/<task-type>/<task>

# Here are some examples:
# $ git checkout -b pm-netbank/fix/update-account-list-style-on-mobile
# $ git checkout -b spare/feature/update-fund-list
# $ git checkout -b framework/internal/create-a-localisation-script

Follow the commit guidelines when committing code into your branch.

  1. When you're done with your work, review your commits to make sure that everything looks right, and that no code outside of the target app has been touched. You then commit your changes to the task branch by:
git add .
git commit
git push -u origin <your-branch-name>

Don't use the -m for adding a git message, since the generated commit message template is added later.

At this point, if others have changed code that you have touched in your branch, you will get a merge conflict. You can find a guide on resolving merge conflicts here. It also always helps to speak to the person your code is conflicting with.

  1. If you had some changes to make, you'll want to push your code again. But since you've already pushed you’ll have to replace the old code with the new code. So run git push --force-with-lease.

  2. Open an MR (merge request) against the master branch on GitLab.

  3. When the merge request has been reviewed and approved by your team it can be merged onto master.

GitLab squashes commits in an MR by default. The purpose of this is to keep the history of the monorepo linear and readable. If you feel it makes sense to have multiple commits, try to rethink how many changes you need to do in the same MR.

You can see a list of all branches you have by running the command git branch.