Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git add on a file excluded by .gitignore

Tags:

git

Is there a way to track a new file in git that is excluded by a rule present in .gitignore? I would like to do this without adding a single file/directory exclusion in my .gitignore rules.

like image 954
Bender the Greatest Avatar asked Sep 19 '25 01:09

Bender the Greatest


1 Answers

Well I was having a tough time finding an answer to this, but to be honest I hadn't tried it yet. Turns out running 'git add' (like below) on a file excluded in .gitignore

git add Test.exe

outputs the following:

The following paths are ignored by one of your .gitignore files:
Test.exe
Use -f if you really want to add them.
fatal: no files added

So revising 'git add' like so will work:

git add -f Test.exe
like image 129
Bender the Greatest Avatar answered Sep 20 '25 15:09

Bender the Greatest