On the terminal, in a repository with unstaged changes, I can do:

~/projects/introduction-to-clojure$ git checkout -f 3.7
Branch '3.7' set up to track remote branch '3.7' from 'origin'.
Switched to a new branch '3.7'

The flag -f makes the command be a forced checkout, ignoring the unstaged changes.

I wish to achieve the same in Magit. Thus, I do: magit-status (C-x g), then magit-branch (b), branch/revision (b), and, finally, I pick 3.7.

However, it does not work and the following error message is provided:

error: Your local changes to the following files would be overwritten by checkout:
Please commit your changes or stash them before you switch branches.

Is it possible to force checkout to a tag in Magit even with unstaged changes? How to do so?

  • 1
    I'm not aware of any direct way to put the -f flag on branch command, and changing transient level doesn't add it as option. Anyway you always can type the command directlty using Q
    – Muihlinn
    Jun 23, 2022 at 7:43

1 Answer 1


Do a hard reset first, if you want to discard the changes. M-x magit-reset-hard (X h) You can also do what is suggested, i.e. commit or stash.

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.