diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-07-17 01:10:45 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-07-17 01:10:45 +0900 |
| commit | b8de3b52ea90b0d41f51a04b820dfae1701e0e91 (patch) | |
| tree | 37c84d40460621630fc5f9b2027cfeb5af9ff689 /.config | |
| parent | e07d8735ab6233b4837a732d6faec2ed0266dcdf (diff) | |
| download | dotfiles-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/config | 8 |
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; \ |
