關於gitignore

  • 2142
  • 0
  • Git
  • 2019-02-09

Git

關於gitignore是專門用來專案忽略在git上,有些檔案我不想放在 Git 裡面
​指令一開始建立.gitignore

$ touch .gitignore

如果跟專案有關,這部分不要忽略,如果非專案可以忽略它

.gitignore

把現有的config忽略
比較常用的C#來說,這些其實在建置C#可以忽略
不必要放置在git裡面

# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
[Bb]in/
[Oo]bj/

# mstest test results
TestResults

## 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/
[Rr]elease/
x64/
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.log
*.vspscc
*.vssscc
.builds

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

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

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*

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

# 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
*.Publish.xml

# NuGet Packages Directory
packages

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
[Bb]in
[Oo]bj
sql
TestResults
[Tt]est[Rr]esult*
*.Cache
ClientBin
[Ss]tyle[Cc]op.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects

# 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

1(.gitignore)的影響範圍是在所在資料夾與子資料夾裡面
2.每個資料夾都可以建置自己(.gitignore),如果他上層有
   (.gitignore),這個資料夾就會受到它影響
3.(#)開頭代表是註解,(/)代表資料夾路徑,檔案名稱可以用
   萬用字元*,(!)代表排除

最近在net core 遇到vs底下編輯,後來還是在.gitignore排除加上這個區塊

.vs/

模板可參考:https://github.com/github/gitignore  

元哥的筆記