Created
July 17, 2025 18:29
-
-
Save grafov/6ca754d47590dd972e35e41de56739fe to your computer and use it in GitHub Desktop.
Backup current Git branch with predefined name based on the date.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my-magit-backup-branch () | |
"Backup current Git branch with predefined name based on the date." | |
(interactive) | |
(let* ((current-branch (magit-get-current-branch)) | |
(branch-name (format "backup-%s-%s" current-branch (format-time-string "%y-%m-%d-%H-%M" (current-time))))) | |
(magit-run-git "branch" "-d" branch-name) | |
(magit-run-git "checkout" "-b" branch-name current-branch) | |
(magit-run-git "push" "--force" "origin" branch-name) | |
(magit-checkout current-branch))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment