47

This is a very basic but I have been unable to find the answer on the web. Is it possible to git rm, i.e. to remove a tracked file, from magit?

Thanks

2
  • The question has been asked and answered on superuser: superuser.com/questions/516639/….
    – Rémi
    Jun 19, 2016 at 13:03
  • There is also magit-do-async-shell-command, which I have bound to "&" in a magit-status buffer.
    – ben_fold
    Nov 22, 2019 at 10:06

2 Answers 2

35

Magit does not provide a command that does git rm (but if you opened a feature request, then I would probably add it eventually).

Meanwhile you can delete the file using some other method, e.g. using M-x delete-file RET <file> RET. Once you have done that refresh the Magit buffer using g and then stage the "deletion" of the file by moving to it in the list of unstaged changes and then pressing s.

22

Magit doesn't support git rm. Instead, delete the folder in dired, and then stage the change.

You can also use ! to launch any git command.

6
  • 45
    K (magit-file-untrack) does git rm --cached
    – npostavs
    Jun 19, 2016 at 13:41
  • 2
    This 'K' key is very usefull. Thanks.
    – wizmer
    Jun 21, 2016 at 1:34
  • @npostavs Why isn't your comment the accepted answer?
    – Daniel
    Jan 11, 2019 at 8:39
  • 1
    @Daniel It's an answer for a different question.
    – npostavs
    Jan 11, 2019 at 13:38
  • 5
    @npostavs Thanks for the comment. I see, so git rm --cached does not remove the file from disk, whereas git rm does. Thanks!
    – Daniel
    Jan 11, 2019 at 15:45

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.