MeltingDog MeltingDog - 1 month ago 8
Git Question

How to remove .swp file that is 'outside repository'

Whenever I try to commit code I get a message:


Found a swap file by the name "/tmp/.commit-message.swp"


I searched SE and found that I could remove it with git rm, eg:

git rm /tmp/.commit-message.swp


But I get the message:


fatal: '/tmp/.commit-message.swp' is outside repository


I have only limited experience in Git. Would anyone know how I can get rid of this?

(note: I searched my drive for this file but could not find it)

Answer

This means your tmp folder is not inside your git project. You can just remove your file by the usual rm command without using git.

Maybe check that you are in the right project, or add this folder to your project first (then remove the file).