GIT對VS工程中的無用檔案過濾
“git clone –bare test test.git”
“git clone test.git test”
使用命令一可以將Git管理的工程test中的映象檔案抽取出來,儲存到test.git目錄(程式碼伺服器中儲存程式碼的形式)中;然後可以使用命令二從映象中恢復工程。我遇到的問題是:從Git控制的映象中恢復VS2010工程,開啟後工程樹預設分類的虛擬目錄消失。即下圖中紅色方框中所示目錄: 只剩下為分類的原始碼檔案。 原因:在將Test工程提交給Git管理時漏掉了Test.vcxproj.filters這個檔案。VS2010中各種型別檔案的作用:
.sln 相當於VC6中 .dsw
.vcxproj 相當於VC6中 .dsp
.suo 相當於VC6中 .ncb
.vcxproj.filters 用於專案下檔案的虛擬目錄
.vcxproj.user 是使用者的一些相關配置
其它檔案和資料夾(res除外)一般都是中間物,在儲存工程時刪除不會有大問題。刪除一些不重要的檔案可以大大減少整個工程檔案大小,節省磁碟空間。
將VS2010工程提交給Git管理時需要哪些檔案:
guyue注: VS2013, 2015的git管理中也是需要這些檔案, *.qrc我猜測就是rc檔案
*.h *.cpp *.sln *.vcxproj *.vcxproj.filters *.qrc
以及Resources目錄下的資原始檔。
如果使用Git的過濾配置,則還需要.gitignore檔案。
其他的諸如*.suo *.sdf *.opensdf *.vcxproj.user均可以過濾掉!
guyue注: 即直接把這些通配檔名(*.suo等)新增到.gitignore檔案中, 一個一行, 即可實現git過濾
以下為guyue 使用VS2015自帶的git管理, 預設生成的.gitignore檔案, 按理說只要把下面內容複製到.gitignore檔案中, 即可實現git對VS工程的各種檔案忽略了
## 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/
# Roslyn cache directories
*.ide/
# 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_*
.*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
## TODO: Comment the next line if you want to checkin your
## web deploy settings but do note that will include unencrypted
## passwords
#*.pubxml
# 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/
bower_components/
# 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/
# LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml