Files
30-seconds-of-code/snippets/current-branch-name.md
Isabelle Viktoria Maciohsek ed2f41b0d8 Bake dates into snippets
2021-06-13 19:47:48 +03:00

20 lines
388 B
Markdown

---
title: Get the current branch name
tags: branch,beginner
firstSeen: 2021-04-04T21:50:46+03:00
lastUpdated: 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.
```shell
git rev-parse --abbrev-ref HEAD
```
```shell
git checkout patch-1
git rev-parse --abbrev-ref HEAD # Prints `patch-1`
```