]> git.phdru.name Git - git-scripts.git/commitdiff
Feat: Add `git-current-branch`
authorOleg Broytman <phd@phdru.name>
Mon, 29 Jan 2024 19:26:22 +0000 (22:26 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 29 Jan 2024 19:26:22 +0000 (22:26 +0300)
List ways to get the current branch name.

git-current-branch [new file with mode: 0755]

diff --git a/git-current-branch b/git-current-branch
new file mode 100755 (executable)
index 0000000..19cedf4
--- /dev/null
@@ -0,0 +1,14 @@
+#! /bin/sh -x
+# List ways to get the current branch name.
+# Compare the output after "git checkout master" and "git checkout master~1".
+
+git branch --show-current
+git describe --all
+git name-rev --name-only HEAD
+
+git rev-parse --abbrev-ref HEAD
+git rev-parse --symbolic-full-name --abbrev-ref HEAD
+
+git symbolic-ref --short -q HEAD; echo $?
+git symbolic-ref --short HEAD
+git symbolic-ref HEAD