-1

My repo consists of a main directory, that has directories in it, and then directories in that. How can I exclude a specific file type from all folders?

I tried including *.exe in the gitignore which is in the main directory, however it still pushes through .exe files that are for instance in mainfolder/secondfolder/thirdfolder/file.exe.

Any advice? Fairly new to this.

Thanks!

Schwern
  • 153,029
  • 25
  • 195
  • 336
  • 3
    Were those .exe files already committed before? Then, you would need to untrack them. – NanoBit Dec 15 '20 at 01:55
  • You might check this https://stackoverflow.com/questions/10712555/gitignore-all-files-of-extension-in-directory if the above is not true. – NanoBit Dec 15 '20 at 01:59
  • 2
    Could you include the evidence you're looking at, rather than just characterizing it and offering your own conclusions about it? `*.exe` in .gitignore excludes all .exe in that directory and all others below it, so something else is interfering, but you've given no evidence anyone can look at to figure out what that might be. – jthill Dec 15 '20 at 02:13

1 Answers1

1

*.exe is correct, but .gitignore will not ignore files which are already tracked. From the NOTES section of the docs.

The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked.

To stop tracking a file that is currently tracked, use git rm --cached.

git add both tells Git to begin tracking a file and adds it to the staging area. If you already added and committed the file, .gitignore has no effect.

git rm will delete the file and untrack it. git rm --cached will only untrack the file, it will not delete the file.

In your example if you want to ignore, mainfolder/secondfolder/thirdfolder/file.exe, but not delete it, add *.exe to .gitignore and git rm --cached mainfolder/secondfolder/thirdfolder/file.exe.

Schwern
  • 153,029
  • 25
  • 195
  • 336