GIT不只僅是個版本控制系統,它也是個內容管理系統(CMS),工做管理系統等。Git 與 SVN 區別點:node
下載地址:https://git-scm.com/downloadsgit
第一步:雙擊下載好的git安裝包,彈出提示框,以下圖:算法
第二步:直接點擊「Next」進入下一步,選擇安裝路徑,以下圖:windows
第三步:選擇好安裝路徑後,點擊「Next」進入下一步,彈出安裝配置窗口,包括git命令行、git圖形窗口等,以下圖所示:後端
Additional icons 附加圖標緩存
Windows Explorer integration Windows資源管理器集成鼠標右鍵菜單安全
Git LFS (Large File Support) 大文件支持
Associate .git* configuration files with the default text editor 將 .git 配置文件與默認文本編輯器相關聯
Associate .sh files to be run with Bash 將.sh文件關聯到Bash運行
Use a TrueType font in all console windows 在全部控制檯窗口中使用TrueType字體
Check daily for Git for Windows updates 天天檢查Git是否有Windows更新
第四步:按照上述默認配置,直接點擊「Next」進入下一步,彈出「選擇開始菜單文件夾」的窗口,以下圖所示:服務器
第五步:按照默認路徑便可,直接點擊「Next」,進入下一步,進入「選擇Git使用的默認編輯器」窗口,以下圖所示:網絡
Use the Nano editor by default 默認使用 Nano 編輯器
Use Vim (The ubiquitous text editor) as Git's default editor 使用 Vim 做爲 Git 的默認編輯器
Use Notepad++ as Git's default editor 使用 Notepad++ 做爲 Git 的默認編輯器
Use Visual Studio Code as Git's default editor 使用 Visual Studio Code 做爲Git 的默認編輯器
Use Visual Studio Code Insiders as Git's default editor 使用Visual Studio Code Insiders 做爲 Git 的默認編輯器
第六步:點擊「Next」,進入下一步,進入「調整Path環境變量」窗口,以下圖所示:app
配置PATH環境
Use Git from Git Bash only
This is the safest choice as your PATH will not be modified at all.You will only be able to use the Git command line tools form Git Bash.
這是最安全的選擇,由於您的PATH根本不會被修改。您只能使用 Git Bash 的 Git 命令行工具。
Use Git from the Windows Command Prompt
This option is considered safe as it only adds some minimal Git wrappers to your PATH to avoid cluttering your environment with optional Unix tools . You will be able to use Git from both Git Bash and the Windows Command Prompt.
這個選項被認爲是安全的,由於它只向PATH添加一些最小的 Git包,以免使用可選的Unix工具混淆環境。 您將可以從 Git Bash 和 Windows 命令提示符中使用 Git。
Use Git and optional Unix tools from the Windows Command Prompt
從Windows命令提示符使用Git和可選的Unix工具
Both Git and the optional Unix tools will be added to you PATH
Git和可選的Unix工具都將添加到您計算機的 PATH 中
Warning:This will override Windows tools like "find and sort".Only use this option if you understand the implications.
警告:這將覆蓋Windows工具,如 「 find 和 sort 」。只有在瞭解其含義後才使用此選項。
第七步:選第二項,而後點擊「Next」進入下一步,選擇HTTPS傳輸後端,以下圖所示:
Use the OpenSSL library
使用 OpenSSL 庫
Server certificates will be validated using the ca-bundle.crt file.
服務器證書將使用ca-bundle.crt文件進行驗證。
Use the native Windows Secure Channel library
使用本地 Windows 安全通道庫
Server certificates will be validated using Windows Certificate Stores.This option also allows you to use your company's internal Root CA certificates distributed e.g. via Active Directory Domain Services.
服務器證書將使用Windows證書存儲驗證。此選項還容許您使用公司的內部根CA證書,例如, 經過Active Directory Domain Services 。
第八步:選擇"Use the OpenSSL library",點擊「Next」進入下一步,配置行結束符,以下圖所示:
Checkout Windows-style,commit Unix-style line endings
Git will convert LF to CRLF when checking out text files.When committing text files,CRLF will be converted to LF .For cross-pltform projects,this is the recommended setting on Windows ("core.autocrlf" is set to "true")
在檢出文本文件時,Git會將LF轉換爲CRLF。當提交文本文件時,CRLF將轉換爲LF。 對於跨平臺項目,這是Windows上推薦的設置(「core.autocrlf」設置爲「true」)
Checkout as-is , commit Unix-style line endings
Git will not perform any conversion when checking out text files. When committing text files, CRLF will be converted to LF. For cross-platform projects,this is the recommended setting on Unix ("core.autocrlf" is set to "input")
在檢出文本文件時,Git不會執行任何轉換。 提交文本文件時,CRLF將轉換爲LF。 對於跨平臺項目,這是Unix上的推薦設置 (「core.autocrlf」設置爲「input」)
Checkout as-is,commit as-is
Git will not perform any conversions when checking out or committing text files.Choosing this option is not recommended for cross-platform projects ("core.autocrlf"is set to "false")
在檢出或提交文本文件時,Git不會執行任何轉換。對於跨平臺項目,不推薦使用此選項(「core.autocrlf」設置爲「false」)
第九步:選擇第一項,點擊「Next」進入下一步,配置終端模擬器,以下圖所示:
Use MinTTY (the default terminal of MSYS2)
Git Bash will use MinTTY as terminal emulator,which sports a resizable window,non-rectangular selections and a Unicode font. Windows console programs (such as interactive Python) must be launched via 'winpty' to work in MinTTY.
Git Bash將使用MinTTY做爲終端模擬器,該模擬器具備可調整大小的窗口,非矩形選區和Unicode字體。 Windows控制檯程序(如交互式Python)必須經過'winpty'啓動才能在MinTTY中運行。
Use Windows' default console window
Git will use the default console window of Windows ("cmd.exe"),which works well with Win32 console programs such as interactive Python or node.js , but has a very limited default scroll-back,needs to be configured to use aUnicode font in order to display non-ASCII characters correctly,and prior to Windows 10 its windows was not freely resizable and it only allowed rectangular text selections.
Git將使用Windows的默認控制檯窗口(「cmd.exe」),該窗口能夠與Win32控制檯程序(如交互式Python或node.js)一塊兒使用,但默認的回滾很是有限,須要配置爲使用unicode 字體以正確顯示非ASCII字符,而且在Windows 10以前,其窗口不能自由調整大小,而且只容許矩形文本選擇。
第十步:選擇第一項,直接點擊「Next」進入下一步,配置額外選項,以下圖所示:
Enable file system caching
啓用文件系統緩存
File system data will be read in bulk and cached in memory for certain operations ("core.fscache" is set to "true"). This provides a significant performance boost.
文件系統數據將被批量讀取並緩存在內存中用於某些操做(「core.fscache」設置爲「true」)。 這提供了顯着的性能提高。
Enable Git Credential Manager
啓用Git憑證管理器
The Git Credential Manager for Windows provides secure Git credential storage for Windows,most notably multi-factor authentication support for Visual Studio Team Services and GitHub. (requires .NET framework v4.5.1 or or later).
Windows的Git憑證管理器爲Windows提供安全的Git憑證存儲,最顯着的是對Visual Studio Team Services和GitHub的多因素身份驗證支持。 (須要.NET Framework v4.5.1或更高版本)。
Enable symbolic links
啓用符號連接
Enable symbolic links (requires the SeCreateSymbolicLink permission).Please note that existing repositories are unaffected by this setting.
啓用符號連接(須要SeCreateSymbolicLink權限)。請注意,現有存儲庫不受此設置的影響。
第十一步:使用默認配置,直接點擊「Install」開始安裝,以下圖所示:
第十二步:安裝完成
第十三步:能夠在cmd裏面測試是否設置了Path,是否安裝成功. 在CMD中輸入 git 或者 git --version 試試
通常工做流程以下:
咱們先來理解下 Git 工做區、暫存區和版本庫概念
.git
目錄下的 index 文件 (.git/index)
中,因此咱們把暫存區有時也叫做索引 (index
)
。
用 git init 在目錄中建立新的 Git 倉庫。 你能夠在任什麼時候候、任何目錄中這麼作,徹底是本地化的。
git init
使用 git clone 拷貝一個 Git 倉庫到本地,讓本身可以查看該項目,或者進行修改。
git clone [url]
git add 命令可將該文件添加到緩存
git add <filename>
git status 以查看在你上次提交以後是否有修改。
git status
git status -s
執行 git diff 來查看執行 git status 的結果的詳細信息。
git diff 命令顯示已寫入緩存與已修改但還沒有寫入緩存的改動的區別。git diff 有兩個主要的應用場景。
使用 git add 命令將想要快照的內容寫入緩存區, 而執行 git commit 將緩存區內容添加到倉庫中。
Git 爲你的每個提交都記錄你的名字與電子郵箱地址,因此第一步須要配置用戶名和郵箱地址。
git config --global user.name 'yourname'
git config --global user.email youremail
將文件寫入緩存區並提供提交註釋
git commit -m 'update message'
git reset HEAD 命令用於取消已緩存的內容。
git reset HEAD -- <filename>
git pull命令用於從另外一個存儲庫或本地分支獲取並集成(整合)。git pull命令的做用是:取回遠程主機某個分支的更新,再與本地的指定分支合併,它的完整格式稍稍有點複雜。
git pull <遠程主機名> <遠程分支名>:<本地分支名>
將遠程存儲庫中的更改合併到當前分支中。在默認模式下,git pull
是git fetch
後跟git merge FETCH_HEAD
的縮寫。更準確地說,git pull
使用給定的參數運行git fetch
,並調用git merge
將檢索到的分支頭合併到當前分支中。
git push
命令用於將本地分支的更新,推送到遠程主機。它的格式與git pull
命令類似。
git push <遠程主機名> <本地分支名>:<遠程分支名>
若是你達到一個重要的階段,並但願永遠記住那個特別的提交快照,你可使用 git tag
給它打上標籤。
好比說,咱們想爲咱們的 商城 項目發佈一個"1.0.0"版本。 咱們能夠用 git tag -a v1.0.0
命令給最新一次提交打上(HEAD) "v1.0.0" 的標籤。
-a
選項意爲"建立一個帶註解的標籤"。 不用 -a 選項也能夠執行的,但它不會記錄這標籤是啥時候打的,誰打的,也不會讓你添加個標籤的註解。 我推薦一直建立帶註解的標籤。
git tag -a v1.0.0
若是咱們要查看全部標籤可使用如下命令:
git tag
TortoiseGit, 中文名海龜 Git. 海龜 Git 只支持 Windows 系統, 有一個前輩海龜 SVN, TortoiseSVN 和 TortoiseGit 都是很是優秀的開源的版本庫客戶端. 分爲 32 位版與 64 位版.而且支持各類語言,包括簡體中文
下載地址:https://download.tortoisegit.org/tgit/
安裝包:TortoiseGit-2.6.0.0-64bit.msi
中文漢化包:TortoiseGit-LanguagePack-2.6.0.0-64bit-zh_CN.msi
咱們須要先安裝程序包,而後安裝語言包(LanguagePack). 由於TortoiseGit 只是一個程序殼,必須依賴一個 Git Core,也就是上一節咱們安裝的 Git. 因此安裝前請肯定已完成上一節的操做. 下面以64位版本爲演示(64,32位除文件名不同,其餘的操做都一致)
第一步:雙擊TortoiseGit安裝包,如圖:
第二步:點擊Next,進入下一步版權信息界面,如圖:
第三步:點擊Next,進入下一步,如圖:
第四步:選擇好安裝路徑,而後點擊Next,進入下一步,如圖:
第五步:點擊Install,開始安裝,如圖:
第六步:等待安裝完成,安裝完成後如圖:
第七步:安裝完成之後在桌面任意空白地方單擊鼠標右鍵,會在右鍵菜單裏找到TortoiseGit,如圖:
第八步:選擇Settings,如圖:
咱們能夠看到,在右邊的語言裏面只有英文,沒有中文。接下來咱們安裝簡體中文語言包
第一步:雙擊打開語言包安裝程序
第二步:點擊Next,進入下一步,如圖:
第三步:等待安裝完成,安裝完成後如圖:
第四步:進入到TortoiseGit設置界面,在右邊的語言裏面選擇簡體中文,而後點擊應用,肯定,漢化即完成,如圖:
不勾選自動升級的複選框,可能還須要指定 Git.exe 文件的路徑
第五步:再次點擊鼠標右鍵,能夠看到彈出菜單中已經變成中文. 原來的 Settings 變成 設置; Clone 變爲 克隆