26

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

18

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.

13

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.

  • 23
    K (magit-file-untrack) does git rm --cached – npostavs Jun 19 '16 at 13:41
  • This 'K' key is very usefull. Thanks. – wizmer Jun 21 '16 at 1:34
  • @npostavs Why isn't your comment the accepted answer? – Daniel Jan 11 at 8:39
  • @Daniel It's an answer for a different question. – npostavs Jan 11 at 13:38
  • @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 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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