diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-07-17 01:36:06 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-07-17 01:36:06 +0900 |
| commit | 85204aa48c485994855870ceca6affc453452725 (patch) | |
| tree | 1d8fa56b3113e8329eb6f3934d8538308c487453 /.config | |
| parent | b8de3b52ea90b0d41f51a04b820dfae1701e0e91 (diff) | |
| download | dotfiles-85204aa48c485994855870ceca6affc453452725.tar.gz dotfiles-85204aa48c485994855870ceca6affc453452725.tar.zst dotfiles-85204aa48c485994855870ceca6affc453452725.zip | |
git/alias: add new alias "git backup-branch"
Diffstat (limited to '.config')
| -rw-r--r-- | .config/git/config | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/.config/git/config b/.config/git/config index 9d0d14b..acef338 100644 --- a/.config/git/config +++ b/.config/git/config @@ -206,3 +206,15 @@ exit 1; \ fi; \ }; __fn" + backup-branch = "!__fn() { \ + if [ \"$1\" = \"\" ]; then \ + local branch=\"$(git current-branch)\"; \ + else \ + local branch=\"$1\"; \ + fi; \ + local sha=$(git rev-parse --short \"$branch\"); \ + local backup_branch=\"bak/$branch/$sha\"; \ + if ! git rev-parse --verify --quiet \"$backup_branch\" > /dev/null 2>&1; then \ + git branch \"$backup_branch\" \"$branch\"; \ + fi; \ + }; __fn" |
