Developer

This section is for Developer operations

Sourcetree

Sourcetree - New branch (start a new feature)

When starting a new feature or start a new bug fixing, MUST branching out from pre_live branch:

  1. Right click on REMOTES > origin > pre_live, click on checkout origin/pre_live
  2. At New local branch name write feature/feature-name (please remember to start with feature/) then click OK
_images/new-branch.png

Sourcetree - Commit Changes

At the FIRST time when commit the changes REMEMBER to tick Push changes immediately to - to let the branches pushed to origin

After the FIRST time can choose to not tick the Push changes immediately to -

_images/commit.png

Sourcetree - Push branch

After code is done, and committed in local, need to push code to remote.

  1. Right click on the REMOTES > feature > feature-1
  2. Choose Push to > origin
_images/push-to-remote.png

Tip

If miss out tick the checkbox in commit stage and the branch is no showing in push window, like

_images/sample-cant-push.png

can choose to (pick only one method below):

  1. Execute following command in terminal:

    git push --set-upstream origin feature/feature-1
    
  2. Amend last commit message and tick the checkbox agn

_images/amend.png

Attention

If a commit is already on remote, please dont simply amend commit message, unless you know what you are doing!!!

Sourcetree - Delete branch

After branch is deleted in remote or when want to remove branch

  1. Be sure NOT in the branch which need to delete
  2. Right click on the branch name, choose Delete branch/name and tick Force delete for prevent it from error (When got changes stuck in the branch is cannot normal delete branch)
_images/delete.png

Sourcetree - Conflict when merging Feature branch to Staging branch

Sometimes staging has many different commit ahead compared to feature(prelive) branch will happen conflict. Since we do not want to make changes on others’ changes, so we need to “discard” those file changes that not changes in current feature branch.

  1. Ensuring those conflict files are not the files you changed

    _images/conflict.png
  2. Right click on the unstaged conflicted file then click Resolve Conflicts > Resolve using 'Mine', repeat on those conflicted files

    _images/resolve-conflict.png
  3. Commit and Push. DONE

Git Command

Git Command - New branch (start a new feature)

git checkout -b feature/feature-1 --track origin/master

Git Command - Commit Changes

# stage all file
git add .
# commit with message
git commit -m "Done feature"

Git Command - Push branch

git push --set-upstream origin feature/feature-1

Git Command - Delete branch

# change branch to other branch
git checkout master
# force delete local branch
git branch -D feature/feature-1

GitLab

After branch was pushed to REMOTES, developer need to create PUSH REQUEST in GitLab

Git Command - Create Merge Request

Inside the GitLab repository project page, click the following buttons

_images/merge-request-1.png
After clicked New merge request, then
  1. At Source branch panel, choose feature branch
  2. At Target branch panel, choose staging/pre_live
  3. Click Compare branches and continue
_images/merge-request-2.png
After clicked Compare branches and continue
  1. Fill in the fields
  2. When merging to
    • STAGING, untick the Delete source branch when merge request is accepted.
    • PRE_LIVE, tick the Delete source branch when merge request is accepted.
  3. Click Submit merge request
_images/merge-request-3.png

Tip

After the merge request submitted still pushing a new commit, the same request will be follow the latest branch status automatically