From 35f43df337267e31837d656f23a69575d54baef6 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 8 Jul 2025 00:55:26 +0900 Subject: git: add alias "git sync-upstream" --- .config/git/config | 11 +++++++++++ 1 file changed, 11 insertions(+) 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" -- cgit v1.2.3-70-g09d2