aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-07-08 00:55:26 +0900
committernsfisis <nsfisis@gmail.com>2025-07-08 00:55:26 +0900
commit35f43df337267e31837d656f23a69575d54baef6 (patch)
treea2dc4869d8681cf3d34a202a0553d7180c3e18a9
parent0a1e38f4ebf71cac9edc228699f70a50919ffffc (diff)
downloaddotfiles-35f43df337267e31837d656f23a69575d54baef6.tar.gz
dotfiles-35f43df337267e31837d656f23a69575d54baef6.tar.zst
dotfiles-35f43df337267e31837d656f23a69575d54baef6.zip
git: add alias "git sync-upstream"
-rw-r--r--.config/git/config11
1 files changed, 11 insertions, 0 deletions
diff --git a/.config/git/config b/.config/git/config
index c5d639d..b9f22a6 100644
--- a/.config/git/config
+++ b/.config/git/config
@@ -191,3 +191,14 @@
echo \"$1\" >> \"$(git rev-parse --git-dir)/info/exclude\"; \
fi; \
}; __fn"
+ sync-upstream = "!__fn() { \
+ local branch=\"$(git current-branch)\"; \
+ if git rev-parse --verify --quiet \"origin/$branch\" > /dev/null 2>&1 && \
+ git rev-parse --verify --quiet \"upstream/$branch\" > /dev/null 2>&1; then \
+ git reset --hard \"upstream/$branch\" && \
+ git push --force-with-lease origin \"$branch\"; \
+ else \
+ echo \"error: branch '$branch' not found on both origin and upstream\" >&2; \
+ exit 1; \
+ fi; \
+ }; __fn"