1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

git: Dynamically identify the "default" branch

This broadly assumes that the "default" remote is called "origin", but
that's better than assuming that plus the default branch name.

Thanks to https://joshtronic.com/2020/08/09/how-to-get-the-default-git-branch/

Suggested-by: Chris Lane <chris@chrislane.com>
Signed-off-by: Joe Groocock <me@frebib.net>
This commit is contained in:
Joe Groocock 2022-05-18 10:46:05 +00:00
parent dcfd191613
commit ba6173e0ee
Signed by: frebib
GPG Key ID: E0B16BEACFBB6A86
2 changed files with 4 additions and 3 deletions

View File

@ -112,7 +112,7 @@ alias gitc='$EDITOR $XDG_CONFIG_HOME/git/config'
alias ggignore='$EDITOR $XDG_CONFIG_HOME/git/gitignore' alias ggignore='$EDITOR $XDG_CONFIG_HOME/git/gitignore'
alias gcl="git clone --recursive" alias gcl="git clone --recursive"
alias gco="git checkout" alias gco="git checkout"
alias gcom="git checkout master" alias gcom="git checkout \"\$(git defbranch)\""
alias ga="git add" alias ga="git add"
alias gap="git add -p" alias gap="git add -p"
alias gau="git add -u" alias gau="git add -u"
@ -136,7 +136,7 @@ alias grba="grb --abort"
alias grbc="grb --continue" alias grbc="grb --continue"
alias grbsk="grb --skip" alias grbsk="grb --skip"
alias grbsh="grb --show-current" alias grbsh="grb --show-current"
alias grbom="git rebase origin/master" alias grbom="git rebase \"origin/\$(git defbranch)\""
gfrb() { remote="${1%/*}"; git fetch "$remote" && git rebase "$@"; } gfrb() { remote="${1%/*}"; git fetch "$remote" && git rebase "$@"; }
gfrbi() { remote="${1%/*}"; git fetch "$remote" && git rebase -i "$@"; } gfrbi() { remote="${1%/*}"; git fetch "$remote" && git rebase -i "$@"; }
@ -160,7 +160,7 @@ alias gp="git push"
alias gpf="gp --force" alias gpf="gp --force"
alias gpsu="git push --set-upstream" alias gpsu="git push --set-upstream"
alias gpoH="git push origin HEAD" alias gpoH="git push origin HEAD"
alias gpsuom="git push --set-upstream origin master" alias gpsuom="git push --set-upstream origin \"\$(git defbranch)\""
alias gpall="git remote | xargs -L1 git push" alias gpall="git remote | xargs -L1 git push"
alias gl="git pull --rebase" alias gl="git pull --rebase"
alias glp="gl && gp" alias glp="gl && gp"

View File

@ -37,6 +37,7 @@
count = !echo $(pwd) && git rev-list HEAD --count count = !echo $(pwd) && git rev-list HEAD --count
unpushed = !git log --oneline @{u}..HEAD unpushed = !git log --oneline @{u}..HEAD
leaders = !git shortlog -s -n --all --no-merges leaders = !git shortlog -s -n --all --no-merges
defbranch = !git symbolic-ref refs/remotes/origin/HEAD | sed \"s@^refs/remotes/origin/@@\"
[advice] [advice]
statusHints = false statusHints = false
pushUpdateRejected = false pushUpdateRejected = false