Last active
          July 21, 2025 22:27 
        
      - 
      
- 
        Save grafov/6eb2937bdca79dd4a9f4afb823d7b7fc to your computer and use it in GitHub Desktop. 
Revisions
- 
        grafov revised this gist Jul 17, 2025 . No changes.There are no files selected for viewing
- 
        grafov created this gist Jul 17, 2025 .There are no files selected for viewingThis 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ (defun my-magit-push-as-another-branch () "Recreate a Magit branch by deleting and creating a new one with branch name completion." (interactive) (let* ((branches (split-string (car (magit-git-items "for-each-ref" "--format=%(refname:short)" "refs/heads/")) "\n")) (branch-name (ivy-read "Enter branch name: " branches :require-match t :preselect (magit-get-current-branch) :sort nil)) (current-branch (magit-get-current-branch))) (when (yes-or-no-p (format "Recreate & push branch \"%s\"?" branch-name)) (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)))