aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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