Backlog uses cookies to deliver our services. By visiting our website, you agree to the use of cookies as described in our Cookie Policy.

See list of branches

$ git branch

Adding the -r option will list the remote tracking branches as well. Adding the -a option will show both remote and local branches.

Create a new branch

$ git branch <branchname>

Work with Git: create a branch

Rename a branch

$ git branch -m <oldbranch> <newbranch>

Delete a branch

$ git branch -d <branchname>

If the branch has not been fully merged with an upstream branch, or in HEAD if there is no upstream, Git will not allow you to delete the branch. You can specify -D however to force delete it irrespective of its merge status.

Work with Git: delete a branch

Switch branches

$ git checkout <branch>

This will allow you to check out and switch to your desired branch.

Adding the -b option will cause a new branch to be created and then checked out.

Learn Git Collaboration: switch branches

Work with Git: switch branches

Merge branches

$ git merge <branch>

Adding the --no-ff option will cause a Git merge to always create a merge commit instead of fast forwarding. This is useful because it allows you to retain the historical information of a branch before it was merged.

Learn Git Collaboration: integrating branches

Work with Git: merge branches