问题
ASP.Net Core项目提交到github,发现把“.vs”“bin/”之类的文件夹也提交上去了。
摸索一下这个.gitignore文件该怎么写。
解决
参考CSDN上另一篇博客ASP.NET和.NET Core项目.gitignore模板
提到另一个项目专门记录各种工程项目的gitignore里面有针对Visual Studio的gitignore模板
下面是一部分示例,全部内容请去github上复制。
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs# Mono auto generated files
mono_crash.*# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
再次git push
写完.gitignore,我就立即add、commit、push了,但什么都没发生。
看另一位大佬的博客Git中使用.gitignore忽略文件的推送,要使用
git rm -r --cached .
跟踪过的文件是无法被忽略的,解决方法就是先把本地缓存删除(改变成未track状态)。
git rm -r --cached .
git add .
git commit -m 'update .gitignore'
git push origin xxxxx
重新push,gitignore要忽略的文件被成功剔除,问题解决!