> For the complete documentation index, see [llms.txt](https://ploegert.gitbook.io/til/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ploegert.gitbook.io/til/tools/git/renaming-a-branch.md).

# Renaming A Branch

The `-m` flag can be used with `git branch` to move/rename an existing branch. If you are already on the branch that you want to rename, all you need to do is provide the new branch name.

```bash
$ git branch -m <new-branch-name>
```

If you want to rename a branch other than the one you are currently on, you must specify both the existing (old) branch name and the new branch name.

```bash
$ git branch -m <old-branch-name> <new-branch-name>
```

h/t Dillon Hafer
