Files
30-seconds-of-code/snippets/git/s/current-branch-name.md
2023-05-07 16:07:29 +03:00

393 B

title, type, language, tags, cover, dateModified
title type language tags cover dateModified
Get the current branch name snippet git
branch
cherry-trees 2021-04-13T21:10:59+03:00

Prints the current branch name.

  • Use git rev-parse --abbrev-ref HEAD to print the name of the current branch.
git rev-parse --abbrev-ref HEAD
git checkout patch-1
git rev-parse --abbrev-ref HEAD # Prints `patch-1`