Search code examples
gitemacsmagit

Magit does not consider ~/.gitignore


Using magit (version: 20190413.1201) with Emacs 26.1, and I notice that magit ignores what my global .gitignore file (~/.gitignore) says. For instance, tilde files (somefile~) continue to show up in magit, but not when using normal command line git (from a proper terminal). Any ideas?

There is a similar question https://emacs.stackexchange.com/questions/14122/both-vc-and-magit-cannot-see-global-gitignore, with the response being:

It turned out Emacs's HOME and Git's were different. I've added the HOME environment variable and moved my .emacs there. All works fine now. Thanks @YoungFrog, you made me think about my HOME

But I don't really understand that sentence. $HOME is the same when querying Emacs or the terminal process.


Solution

  • For instance, tilde files (somefile~) continue to show up in magit,

    Make sure those files are not already versioned (tracked by Git), because no amount of .gitignore (global or not) would remove them from Git/Magit consideration.
    You would need to remove them (git rm --cached) first, before seeing those files not showing up anymore.