Creating a New Branch

See https://git-extensions-documentation.readthedocs.io/en/latest/branches.html#create-branch

Command line

git checkout -b <BranchName> [origin/<RemoteBranchName>]​
git checkout -b <BranchName> [CommitOrRef]
​git branch <BranchName> [CommitOrRef]

Create on top of remote branch instead of local

Most of time we'd like to create our branch basing on the remote branch for example origin/master, instead of a local master. A local master branch is only needed when we want to push something directly to the remote master. If commits are meant to be merged through pull requests, we can delete it to avoid inadvertently push to the remote master branch.

Fetch before creating

Most of time we'd like to fetch the remote branch first before creating branch, because the origin/master on our PC might not be up to date as the branch on remote server.

Fetch & Create in one go

In the left branch tree panel, find the remote branch, right click and select the menu Fetch & Checkout if want to use the same name as the local branch name or Fetch & Create Branch if a different name needed.

Last updated