git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Change git-branch to list branches

From
KVKalle Valo <kalle.valo@iki.fi>
Date
Aug 16, 2005, 17:58 UTC
Message-ID
<87d5odlq6l.fsf_-_@litku.valo.iki.fi>
In-Reply-To
<87hddplqdu.fsf@litku.valo.iki.fi>

If no argument provided to `git branch`, show available branches and mark current branch with star.

This is based on patch written by Amos Waterland <apw@rossby.metr.ou.edu>.
Signed-off-by: Kalle Valo <Kalle.Valo@iki.fi>
---
 git-branch-script |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
38aca3bb4ad4e6b0e10e295a87a9f5ce37ff5be4
diff --git a/git-branch-script b/git-branch-script
--- a/git-branch-script
+++ b/git-branch-script
@@ -11,7 +11,13 @@ case "$2" in
 esac
 rev=$(git-rev-parse --revs-only --verify "$head") || exit
 
-[ -z "$branchname" ] && die "git branch: I want a branch name"
+if [ -z "$branchname" ]; then
+    current=$(basename $(readlink $GIT_DIR/HEAD))
+    cd $GIT_DIR/refs/heads &&
+    ls | sed -e "s/^/  /" -e "s/  $current/* $current/"
+    exit
+fi
+
 [ -e "$GIT_DIR/refs/heads/$branchname" ] && die "$branchname already exists"
 
 echo $rev > "$GIT_DIR/refs/heads/$branchname"
Previous: Kalle ValoNext: Junio C Hamano
Message 3 of 7 in “Add git-branches-script”
  1. Add git-branches-scriptAmos Waterland, Aug 15, 2005
  2. Kalle ValoAug 16, 2005
  3. Change git-branch to list branchesKalle Valo, Aug 16, 2005
  4. Junio C HamanoAug 16, 2005
  5. Kalle ValoAug 17, 2005
  6. Kalle ValoAug 17, 2005
  7. Miguel BazdreschAug 17, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.