gitignore重要技巧
生活随笔
收集整理的這篇文章主要介紹了
gitignore重要技巧
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
問題:在某個開發項目中,我用gitignore指定需要git的文件,但突然新增一個子目錄,而這子目錄下,有非常多的子目錄和各級目錄還有各種不同的格式的文件,按照原來的方法,一個個添加.gitignore文件非常的麻煩,而且容易出錯,又耗時?
解決方案:
將.gitignore文件其用途,反過來用,原來只限定上傳的文件,現在只限定不上傳的文件
比如說:
原來: * !.py !main_dir/修改: test/ ess/.gitignore要學會正反都拿來用,然后根據實際情況來處理,思維方式轉換非常節約時間且高效。
Double Asterisk ** can be used to match any number of directories.**/logs matches all files or directories named logs (same as the pattern logs) **/logs/*.log matches all files ending with .log in a logs directory logs/**/*.log matches all files ending with .log in the logs directory and any of its subdirectories ** can also be used to match all files inside of a directory, so for example logs/** matches all files inside of logs比如說我要過濾各個目錄下的所有__pycache__文件夾
在.gitignore文件中添加
**/__pycache__
過濾掉所有的某種類型的文件,如圖所示:
僅僅使用:*.csv就可以了,就可以匹配任何目錄下的csv文件。如果只想匹配當前目錄下的需要加個/*.csv
?
總結
以上是生活随笔為你收集整理的gitignore重要技巧的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux下的tmpfs目录重启后文件全
- 下一篇: 自动生成requirements.txt