-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
- Get default branch name
Option 1a.git remote show <remote_name> | grep 'HEAD branch' | cut -d' ' -f5
Option 1b.git branch -r --points-at refs/remotes/origin/HEAD | grep '\->' | cut -d' ' -f5 | cut -d/ -f2
Option 1c.git remote show <remote_name> | awk '/HEAD branch/ {print $NF}'
Option 1d.
upstream-name = !git remote | egrep -o '(upstream|origin)' | tail -1
head-branch = !git remote show $(git upstream-name) | awk '/HEAD branch/ {print $NF}'
Option 1e. git rev-parse --abbrev-ref origin/HEAD will print origin/<default-branch-name>
Option 1f. git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'
Option 1g. git remote show <remote_name> | grep "HEAD branch" | cut -d ":" -f 2
Option 1i.
( set -- `git ls-remote --symref origin HEAD`
test $1 = ref: && echo $2 )
NB. <remote_name> is normally origin)
- Assign an alias branch name and use it in scripts
Option 2a.git symbolic-ref refs/heads/default refs/heads/<default-branch>
Note: one can still checkoutdefaultas such and any operations withdefaultbranch will just update the bound branch pointer. Current branch will be the bound branch, however bash prompt still may showdefault
Metadata
Metadata
Assignees
Labels
No labels