我嘗試使用.gitkeep,但無論我嘗試過什麼,它都不起作用。如何使用git來追蹤文件夾結構?
比如我有一個文件夾結構是這樣的:
.
├── a
│ ├── aa
│ │ ├── aaa
│ │ │ ├── .gitkeep
│ │ │ └── test.txt
│ │ ├── .gitkeep
│ │ └── test.txt
│ ├── .gitkeep
│ └── test.txt
├── b
│ ├── bb
│ │ ├── bbb
│ │ │ └── test.txt
│ │ ├── .gitkeep
│ │ └── test.txt
│ └── test.txt
└── .gitignore
我有過這樣的的.gitignore:
*
!a/.gitkeep
!*/.gitkeep
!**/.gitkeep
!.gitignore
這樣做是爲了保持所有的文件夾與.gitkeep。令人驚訝的是,沒有文件夾將被跟蹤這個配置。
有誰能告訴我爲什麼這不起作用?
你只需要'.gitkeep'文件在沒有任何其他內容的目錄中。在你的情況下,各種'test.txt'文件使它們成爲冗餘。 – jonrsharpe