Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Head branch #10138

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 2 additions & 9 deletions plugins/git/git.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,10 @@ function work_in_progress() {
fi
}

# Check if main exists and use instead of master
# Return the head branch
function git_main_branch() {
command git rev-parse --git-dir &>/dev/null || return
local branch
for branch in main trunk; do
if command git show-ref -q --verify refs/heads/$branch; then
echo $branch
return
fi
done
echo master
git branch -rl "*/HEAD" | rev | cut -d/ -f1 | rev
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@' should also work if you prefer to use sed instead of rev and cut but all of these are pretty standard tools that should be available in any system running git on zsh....

}

# Check for develop and similarly named branches
Expand Down