From 85204aa48c485994855870ceca6affc453452725 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 17 Jul 2025 01:36:06 +0900 Subject: git/alias: add new alias "git backup-branch" --- .config/git/config | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to '.config') 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" -- cgit v1.2.3-70-g09d2