As @Tarsius mentions, you can define your own command to do this.
(defun wh/magit-branch-from-current-and-checkout (branch)
"Create and checkout BRANCH from the current branch."
(interactive (list (magit-read-string-ns "Branch name")))
(let ((start-point (magit-get-current-branch)))
(if (string-match-p "^stash@{[0-9]+}$" start-point)
(magit-run-git "stash" "branch" branch start-point)
(magit-call-git "checkout" "-b" branch start-point)
(--when-let (and (magit-get-upstream-branch branch)
(magit-get-indirect-upstream-branch start-point))
(magit-call-git "branch" (concat "--set-upstream-to=" it) branch))
(magit-refresh))))
You can add this to the existing branch popup. In this case, I've chosen b f as the keybinding (as it's currently unused).
(magit-define-popup-action 'magit-branch-popup
?f "new branch From current" #'wh/magit-branch-from-current-and-checkout)
If you don't have unpushed commits on your current branch, you can also use b s (bound to magit-branch-spinoff
) to create a new branch without prompting for the base branch.
master
branch will be used by default. This default may change depending on your previous choices. Always branching frommaster
branch is not very good idea too. It may seem so if you work with simple pet projects, but once you work in a team, using something like git-flow, you will want to always explicitly choose