Skip to content

Instantly share code, notes, and snippets.

@tony-sol
Last active April 17, 2024 14:57
Show Gist options
  • Save tony-sol/00eb6393b1df1b70d90c07ddd937434f to your computer and use it in GitHub Desktop.
Save tony-sol/00eb6393b1df1b70d90c07ddd937434f to your computer and use it in GitHub Desktop.

Revisions

  1. tony-sol revised this gist Apr 17, 2024. No changes.
  2. tony-sol created this gist Apr 17, 2024.
    10 changes: 10 additions & 0 deletions git-get-head
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    #!/bin/zsh

    set -e

    git_get_head() {
    (git symbolic-ref "refs/remotes/${@}/HEAD" --short || git remote show "${@}" ) 2>/dev/null | grep "${@}/\|HEAD branch" | sed -E "s#${@}/|HEAD branch:##" | sed 's# ##g'
    }

    git_get_head "${1}"
    exit 0