-1

I have this dictionary hierarchy:

.
|-- Test
|   |-- file_c.z
|   `-- sub-dir
|       |-- file_d.t
|       `-- file_e.q
|-- file_a.x
|-- file_b.y
`-- .gitignore

Now how can I tell git ignore everything except file_a.x and file_e.q?

Bình Nguyên
  • 2,112
  • 6
  • 28
  • 46
  • possible duplicate of [Make .gitignore ignore everything except a few files](http://stackoverflow.com/questions/987142/make-gitignore-ignore-everything-except-a-few-files) – Chris Maes Jan 20 '15 at 11:15
  • @ChrisMaes: I've already read that question but it not resolve my problem – Bình Nguyên Jan 20 '15 at 11:19

3 Answers3

1

Add following to your .gitignore

# Ignore everything
*
# Don't ignore .gitignore and your specific files files
!.gitignore
!file_a.x
!Test/sub-dir/file_e.q
deimus
  • 9,154
  • 11
  • 56
  • 103
0

You can use an asterisk as wildcard.

Test/sub-dir/file_d.*
René Höhle
  • 25,733
  • 22
  • 69
  • 78
0

you can exclude files from gitignore patterns with '!'

just write

Test/
!file_a.x
!file_e.q

in your .gitignore

clash
  • 532
  • 4
  • 17