aboutsummaryrefslogtreecommitdiff
path: root/.alias.d
diff options
context:
space:
mode:
authorRaul Benencia <raul@thousandeyes.com>2024-04-17 10:26:30 -0700
committerRaul Benencia <raul@thousandeyes.com>2024-04-17 10:26:30 -0700
commitda4e2b14657895b4604a78e0f674028d650a6e22 (patch)
treedd91fa0d8acbc1444c4aaae3bc62655991e51fd6 /.alias.d
parentf0ebe4f354866b74dfda52f4763621b3062a81e0 (diff)
sh: convert a few git aliases to functions
Diffstat (limited to '.alias.d')
-rw-r--r--.alias.d/10-git25
1 files changed, 22 insertions, 3 deletions
diff --git a/.alias.d/10-git b/.alias.d/10-git
index 9bb1906..ac82cda 100644
--- a/.alias.d/10-git
+++ b/.alias.d/10-git
@@ -29,7 +29,6 @@ alias gcf='git config --list'
alias gcl='git clone --recursive'
alias gclean='git clean -fd'
alias gpristine='git reset --hard && git clean -dfx'
-alias gcm='git checkout master && git fetch upstream && git reset --hard upstream/master'
alias gco='git checkout'
alias gcount='git shortlog -sn'
@@ -126,8 +125,28 @@ alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit -m "--wip--"'
alias git-delete-merged-branches='git branch --merged | grep -v "\*" | grep -v master | xargs -n 1 git branch -d'
alias gfrh='git fetch && git reset --hard "origin/$(git rev-parse --abbrev-ref HEAD)"'
-alias gfr='git fetch upstream && git rebase upstream/master'
# mr
alias ms='mr -m status'
-alias mp='mr push' \ No newline at end of file
+alias mp='mr push'
+
+main_branch() {
+ if git branch --list | grep -q master; then
+ echo master
+ else
+ echo main
+ fi
+}
+
+gcm() {
+ branch=$(main_branch)
+ git checkout "$branch"
+ git fetch upstream
+ git reset --hard "upstream/${branch}"
+}
+
+gfr() {
+ branch=$(main_branch)
+ git fetch upstream
+ git rebase "upstream/${branch}"
+}
nihil fit ex nihilo