reset to merge base and upstream functions
This commit is contained in:
parent
ea590912f6
commit
a98c753d77
|
|
@ -681,3 +681,41 @@
|
|||
:chat-model "codellama:latest"
|
||||
:embedding-model "nomic-embed-text"
|
||||
:default-chat-non-standard-params '(("num_ctx" . 8192)))))
|
||||
|
||||
|
||||
(defun magit-reset-to-merge-base ()
|
||||
"Reset to merge-base of two branches using Magit's branch selection."
|
||||
(interactive)
|
||||
(require 'magit)
|
||||
(let* ((branch1 (magit-read-branch "Select first branch: "))
|
||||
(branch2 (magit-read-branch "Select second branch: "))
|
||||
(merge-base (magit-git-string "merge-base" branch1 branch2)))
|
||||
(if merge-base
|
||||
(progn
|
||||
(magit-reset-internal "--soft" merge-base)
|
||||
(message "Reset to merge-base of %s and %s" branch1 branch2))
|
||||
(user-error "No merge-base found between %s and %s" branch1 branch2))))
|
||||
|
||||
(defun magit-reset-to-upstream ()
|
||||
"Reset to upstream of the current branch using Magit."
|
||||
(interactive)
|
||||
(require 'magit)
|
||||
(let ((current-branch (magit-get-current-branch)))
|
||||
(if current-branch
|
||||
(let ((upstream (magit-get-upstream-branch current-branch)))
|
||||
(if upstream
|
||||
(progn
|
||||
(magit-reset-internal "--soft" "@{u}")
|
||||
(message "Reset to upstream of %s (%s)" current-branch upstream))
|
||||
(user-error "No upstream branch set for %s" current-branch)))
|
||||
(user-error "Not on a branch"))))
|
||||
|
||||
|
||||
(global-set-key (kbd "C-x g r b") 'magit-reset-to-merge-base)
|
||||
(global-set-key (kbd "C-x g r u") 'magit-reset-to-upstream)
|
||||
|
||||
|
||||
|
||||
(provide 'init)
|
||||
|
||||
;;; init.el ends here
|
||||
|
|
|
|||
Loading…
Reference in New Issue