tags:

views:

60

answers:

4

I have a gitignore file that makes git ignore *.dll files, and that is actually the behavior I want. However, if I want an exception ( i.e. to be able to commit foo.dll), how can I achieve this?

+4  A: 

Just add ! before an exclusion rule.

According to the gitignore man page:

Patterns have the following format:

...

  • An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence patterns sources.
Robert Munteanu
+8  A: 

Use:

*.dll    #Exclude all dlls
!foo.dll #Except for foo.dll

From gitignore:

An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence patterns sources.

Skilldrick
+5  A: 

You can simply git add -f path/to/foo.dll.

.gitignore ignores only files for usual tracking and stuff like git add .

Nils Riedemann
+1  A: 

!foo.dll in .gitignore, or (every time!) git add -f foo.dll

Tobias Kienzler