17

My code structure is:

.gitignore
my-service << this is a file without an extention
charts
| my-service << this is a folder
| | file1
| | file2

When I write in my gitignore my-service it ignores both my-service the file and my-service the folder. How can I ignore only the file in the root directory, and not the sub-directory?

Calrion
  • 3,202
  • 1
  • 28
  • 30
Naguib Ihab
  • 4,259
  • 7
  • 44
  • 80
  • Perhaps this might be useful : https://www.2brightsparks.com/bb/viewtopic.php?t=10067 – Rann Lifshitz Mar 22 '18 at 04:54
  • Possible duplicate of [How to exclude file only from root folder in Git](https://stackoverflow.com/questions/3637660/how-to-exclude-file-only-from-root-folder-in-git) – max630 Mar 22 '18 at 08:43

1 Answers1

33

you can do the reverse way with! in .gitignore

myservice
!myservice/
Yu Jiaao
  • 4,444
  • 5
  • 44
  • 57