gpt4 book ai didi

git - Visual Studio 的 .gitignore 文件

转载 作者:太空狗 更新时间:2023-10-29 14:00:31 26 4
gpt4 key购买 nike

我已经为我的 visual studio 2013 windows 窗体应用程序添加了 .gitignore 文件。它运行良好,但问题是当我清理或重建我的项目时,我在运行 git status 时出现了以下两个文件。这两个文件出现了爆裂声如下。

deleted:    MyTestProject/bin/Debug/MyTestProject.exe.config
deleted: MyTestProject/obj/Debug/MyTestProject.csproj.FileListAbsolute.txt

重建时只有第二个文件出现。这是为什么 ?因为 .gitignore 文件的设计使得只有更改后的源代码文件才会显示在 gitstatus 中,而我只是在清理或重建。此外,当我运行我的项目时,第一个删除的文件没有显示在 git status 中。

现在还应该在 .gitignore 文件中添加什么来忽略这两个文件。

以下是.gitignore的内容

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
x64/
build/
bld/
[Bb]in/
[Oo]bj/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

#NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding addin-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
_NCrunch_*
.*crunch*.local.xml

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml

# NuGet Packages Directory
packages/
## TODO: If the tool you use requires repositories.config uncomment the next line
#!packages/repositories.config

# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
# This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
!packages/build/

# Windows Azure Build Output
csx/
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

最佳答案

有点不清楚实际问题是什么,但假设您希望 Git 忽略由 Visual Studio 中的构建生成的文件:

Visual Studio 习惯于在输出目录中放置大量不同类型的文件,因此只需将它们添加到 .gitignore 即可:

MyTestProject/bin/
MyTestProject/obj/

编辑:

详细说明:最常见的期望行为是让 Git 忽略由构建(或重建,就此而言)创建的任何文件。由于 VS 将 很多 文件放入它所指的输出目录和中间目录中,因此让 Git 忽略这些目录 通常要容易得多,而不是每个 em>文件里面。忽略文件扩展名只会让你到目前为止,例如,如问题中所述,VS 似乎生成了一个 .txt 文件,并且可能不想要忽略所有 此类文件。人们也不想通过 .gitignore 中的完整路径列出每个生成的文件,部分原因是因为文件太多,部分原因是它们可能会随着时间而改变。

关于git - Visual Studio 的 .gitignore 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22732340/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com