> For the complete documentation index, see [llms.txt](https://kathfoss.gitbook.io/git/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kathfoss.gitbook.io/git/commands/branches.md).

# Branches

## Creating a Branch

* **`git branch <branch-name>`**

  -creates a new branch with the name "\<branch-name>"

## Listing Branches

* **`git branch`**&#x20;

  -lists all the local branches.<br>
* **`git branch -r`**

  -lists all the remote branches.<br>
* **`git branch -a`**

  -lists all branches.

## Changing branches

* **`git checkout <branch-name>`**

  -Switch to the existing branch "\<branch-name>" and update the working directory.<br>
* **`git checkout -b <branch-name>`**

  -Create a new branch "\<branch-name>" with current branch as parent branch and switch to the \<branch-name>&#x20;

## Deleting Branches

* **`git branch -d <branch-name>`**

  -delete a branch that is merged.
* **`git branch -D <branch-name>`**

  -delete a branch, whether merged or not.
