The meaning of life is to explore the world

Git branching tips

Posted on By Jason Liu

Some tips of Git branching

  1. Creating a local branch
    git branch <target branch> <source branch>
    Create a local branch and switch to that branch:
    git checkout -b <target branch> <source branch>
    If <source branch> is omitted then it’ll branch from the current branch.
    It can be a problem if we branch from X branch, push then create pull request to merge into Y branch.

  2. We don’t need to have an exsiting remote branch for the push, otherwise we’ll have to pull and merge locally first.

  3. Creating pull request after pushing may cause merge conflict, which happens after code review approval in Azure DevOps.

  4. Deleting a local branch with git branch -D <branch name>