aboutsummaryrefslogtreecommitdiffhomepage
path: root/.config
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-07-17 01:10:45 +0900
committernsfisis <nsfisis@gmail.com>2025-07-17 01:10:45 +0900
commitb8de3b52ea90b0d41f51a04b820dfae1701e0e91 (patch)
tree37c84d40460621630fc5f9b2027cfeb5af9ff689 /.config
parente07d8735ab6233b4837a732d6faec2ed0266dcdf (diff)
downloaddotfiles-b8de3b52ea90b0d41f51a04b820dfae1701e0e91.tar.gz
dotfiles-b8de3b52ea90b0d41f51a04b820dfae1701e0e91.tar.zst
dotfiles-b8de3b52ea90b0d41f51a04b820dfae1701e0e91.zip
git/alias: improve "git sync-upstream"
Diffstat (limited to '.config')
-rw-r--r--.config/git/config8
1 files changed, 6 insertions, 2 deletions
diff --git a/.config/git/config b/.config/git/config
index b9f22a6..9d0d14b 100644
--- a/.config/git/config
+++ b/.config/git/config
@@ -192,10 +192,14 @@
fi; \
}; __fn"
sync-upstream = "!__fn() { \
- local branch=\"$(git current-branch)\"; \
+ if [ \"$1\" = \"\" ]; then \
+ local branch=\"$(git current-branch)\"; \
+ else \
+ local branch=\"$1\"; \
+ fi; \
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 branch --force \"$branch\" \"upstream/$branch\" && \
git push --force-with-lease origin \"$branch\"; \
else \
echo \"error: branch '$branch' not found on both origin and upstream\" >&2; \