前段時間我我.gitignore
文件設置爲不跟蹤的文件夾my_folder
有:跟蹤文件中忽略目錄
my_folder/
現在我只希望跟蹤給定的文件中說,文件夾,命名爲my_file.md
。製作後.gitignore
是這樣的:
my_folder/
!my_folder/my_file.md
和檢查:
git status
該文件不顯示爲被提交的修改。
我在做什麼錯?
添加
我試圖改變我的.gitignore
文件:
my_folder/*
!my_folder/my_file.md
的建議,但該文件是仍然沒有顯示出來的變化git status
後提交。我需要重置一些東西嗎?
添加2
試圖將文件添加與git add my_folder/my_file.md
回報:
The following paths are ignored by one of your .gitignore files:
my_folder/my_file.md
Use -f if you really want to add them.
fatal: no files added
命令git check-ignore -v my_folder/my_file.md
給出:
.gitignore:1:my_folder/* my_folder/my_file.md
杜佩 - 但簡短的答案是使用「my_folder/*」http://stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder – 2014-10-04 02:49:19
謝謝@AndrewC,我試過但它仍然沒有工作。不知道我做錯了什麼。 – Gabriel 2014-10-04 14:33:40
既然你*真的*想添加* my_folder/my_file.md *爲什麼不使用'-f'標誌,因爲它告訴你? – PSkocik 2014-10-04 15:54:08