diff options
| -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" |
