user6949100
user6949100

Reputation:

Why doesn't my project .gitignore work? The global .gitignore does

I can't get git to ignore any files or folders listed in .gitignore.

  1. Create empty .gitignore file in same folder as .git. To be clear, it's not inside of the .git folder, it's in the project root folder.
  2. Add one line "stupidfilename" to .gitignore.
  3. Create "stupidfilename", which has never existed in the repo.
  4. Run "git add ."
  5. Gasp as "stupidfilename" is staged.

Files listed in my global .gitignore file are successfully ignored. But I'd like to have project-level ignores.

Setup

Any idea what's going on here? I can't find any explanation on the internet.

Upvotes: 0

Views: 289

Answers (1)

Mohit Mutha
Mohit Mutha

Reputation: 3001

.gitignore does not work if you put it in the .git directory. It should be in your source or working directory

Possibly a repeat of this question Where does the .gitignore file belong?

Upvotes: 2

Related Questions