1

I've tried a lot of patterns, but non of them works, and the file still synced with the remote server (GitHub): I have a text file inside the project folder:

ProjFolder
   secret.txt
.gitignore

I want to ignore the file secret.txt. I tried:

./secret.txt
/secret.txt
*/secret.txt

and a lot more that I can't remember. Is it possible to ignore file that's not in the same .gitignore directory?!

mshwf
  • 7,009
  • 12
  • 59
  • 133

2 Answers2

2

If you want to ignore it from now on, you should use

git rm --cached project/secret.txt
cat project/secret.txt >> .gitignore
git commit -a -m "Remove secret.txt"

Ignore rule will be effective only after you removed that file.

If you want to remove it from all history, you should search usage of git filter-branch and rewrite all history to remove this file.

networm
  • 349
  • 2
  • 4
0

You need to specify it's path in your .gitignore file:

ProjFolder/secret.txt
Mureinik
  • 297,002
  • 52
  • 306
  • 350