3

When I am working on the Command Line Interface, I can do:

$ git branch

Then, I can see all the local branches that I have created. On Magit, If I do b l (check out local branch), there is a prompt to answer. With the auto-complete, I can find all the local branches I created.

However, when I press tab to see the suggestions, Magit lists absolutely all branches, the ones I created locally and the ones pulled from the upstream remote repository.

Is there a way to limit the suggestions for the branch checkout only to the branches I have created?

1
  • 1
    I'm wondering why you'd want that in the first place, since non-local branches have a prefix. AFAIK, it's not possible. You can always run M-! git branch RET.
    – aadcg
    Commented Aug 2, 2021 at 12:13

1 Answer 1

3

Here's a quick hack using magit-read-local-branch:

(defun my-checkout-local-branch ()
  (interactive)
  (let ((branch (magit-read-local-branch "Branch: ")))
    (magit-checkout branch)))

(transient-append-suffix 'magit-branch "w"
  '("L" "my branch" my-checkout-local-branch))

Though it won't do stuff like filtering out the branch you're currently on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.