🎓 A1Learner
🔍
0 of 50 lessons completed

Rename a Branch

Rename gives a branch a better name. The snapshots stay exactly where they were.

Rename the branch

The name changes. Nothing else moves.

$ git branch -m add-recipe add-pancakes
$ git branch

Rename it back

The old name returns just as easily.

$ git branch -m add-pancakes add-recipe
$ git branch

Example

$ git branch -m add-recipe add-pancakes
$ git branch

Key points

  • Rename with -m and the old name and the new name.
  • The history does not change. Only the name changes.
  • Rename a branch before you share it, not after.
  • List the branches to check the new name.

Here, the branch gets a clearer name. The star stays on it. Nothing else changes.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

Which command renames a branch?