我正在寻找创建一个.gitignore文件,以便某些文件不会被检入存储库.有没有人有关于如何以及在何处放置此文件的指南?我已经尝试将它放在我的工作目录中,运行git status并且它仍在接收我希望它忽略的文件.
我用过这个.gitignore文件我找到了:
###################
# compiled source #
###################
*.com
*.class
*.dll
*.exe
*.pdb
*.dll.config
*.cache
*.suo
# Include dlls if they’re in the NuGet packages directory
!/packages/*/lib/*.dll
# Include dlls if they're in the CommonReferences directory
!*CommonReferences/*.dll
####################
# VS Upgrade stuff #
####################
UpgradeLog.XML
_UpgradeReport_Files/
###############
# Directories #
###############
bin/
obj/
TestResults/
###################
# Web publish log #
###################
*.Publish.xml
#############
# Resharper #
#############
/_ReSharper.*
*.ReSharper.*
############
# Packages #
############
# it’s better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
######################
# Logs and databases #
######################
*.log
*.sqlite
# OS generated files #
######################
.DS_Store?
ehthumbs.db
Icon?
Thumbs.db
Run Code Online (Sandbox Code Playgroud)
Pet*_*oes 21
.gitignore的放置取决于是否需要忽略一个仓库或所有仓库的文件.对于一个仓库,将其放在您的仓库的根目录中.
在现有仓库中创建.gitignore文件或添加已在仓库中的文件时,必须确保从仓库中删除要忽略的文件.
如果你在root中有一个test.dll,你必须这样做
git rm --cached test.dll
Run Code Online (Sandbox Code Playgroud)
现在,如果你有很多文件,就像你说你可以选择以下选项,从缓存中删除所有内容,将其全部添加回来(不会添加.gitignore中的文件)并再次提交所有内容.
git rm -r --cached .
git add .
git commit -m "Start using .gitignore"
Run Code Online (Sandbox Code Playgroud)
Fre*_*ihl 11
你必须.gitignore在git看到它之前添加到索引.即git add .gitignore
| 归档时间: |
|
| 查看次数: |
50780 次 |
| 最近记录: |