例舉dotNet開發的一個場景來講明「忽略文件」的做用,在開發過程當中每每在編輯代碼後,VS在每次編譯後會生成一些項目構建文件例如bin目錄、obj目錄等。然而這些文件並不須要進行版本控制,由於每一個人每次編譯後都會自動生成,若是頻繁上傳至Git那麼會形成空間的佔用,其餘人檢出文件時增長下載的時間。因此在第一次將項目使用Git版本控制時,就須要建立該文件,來避免相似的問題。html
基於以上的場景,說到底就是咱們不但願項目中的文件進行版本控制(忽略掉),那麼此時就能夠配置一個全局的忽略文件.gitignore。node
建立全局的忽略文件.gitignore步驟以下:git
1.選擇一個目錄(推薦Git安裝目錄),在該目錄打開Git命令行工具,輸入命令(建立忽略文件):github
touch .gitignore_global
2. 將該文件配置爲全局的忽略文件,輸入命令:web
git config --global core.excludesfile ~/.gitignore_global
3.打開.gitignore_global文件添加忽略規則,在這裏不詳細介紹規則的編寫,由於這些東西每每都是通用化的都用現有的模板拿來用,若是不是專門的版本控制系統管理員,那就沒必要浪費時間研究。以下附上一個模板,能夠根據模板內容自行擴展:json
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# 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
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_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
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# 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 add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# 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 database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#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/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
4.另外須要強調的一點:若是你的項目已經創建Git版本庫,那這個時候在添加.gitignore文件後是沒有效果的,須要咱們手動刪除緩存,命令以下:緩存
git rm -r --cached .
GitHub是基於Git版本控制系統並將項目工程架設到雲端進行託管的平臺。下面以項目經理和開發人員創建新項目的維度來介紹GitHub的使用流程。sass
注:若是是進行演練操做,請自行準備好兩個GitHub帳號分別對應項目經理和開發人員。app
在項目根目錄打開Git命令行工具,輸入:ide
git init
操做參考圖:
操做參考圖:
操做命令:
git add * git commit -m "註釋"
7.4.2.在GitHub上建立項目
操做參考圖1:
操做參考圖2:
操做參考圖3:
至此建立完成。
操做命令:
git remote add <遠端代號> <遠端地址>
<遠端代號> :鏈接代號。通常直接使用origin做代號,也能夠自定義。至關於存儲遠端地址的變量名稱。
<遠端地址> :GitHub項目的Url。
操做參考圖:
注:以上配置的信息能夠在隱藏目錄.git下的config文件中查看。
操做命令:
git push <遠端代號> <本地分支名稱>
輸入命令後會提示輸入GitHub的用戶名和密碼
操做參考圖:
至此推送完畢。
在GitHub查看推送的結果:
輸入操做命令:
git clone <GitHub遠程URL>
操做參考圖:
操做參考圖:
操做參考圖:
點擊綠色按鈕進行邀請,邀請後複製用於邀請對方的URL:
操做參考圖:
操做命令:
git push origin master
操做參考圖:
PS:輸入push命令後會要求填寫用戶名和密碼。
操做命令:
git pull origin master
操做參考圖: