前言
最初,Git是用於Linux下的內核代碼管理。因為其非常好用,目前,已經被成功移植到Mac和Windows操作系統下。
鑒於大部分使用者使用的是Windows操作系統,故,這里詳細講解Windows操作系統下Git的安裝步驟。
當然我也會陸續寫出Linux和Mac操作系統下Git的安裝步驟。
安裝前的說明
Git在windows平台上安裝說明。
Git 是 Linux Torvalds 為了幫助管理 Linux 內核開發而開發的一個開放源碼的版本控制軟件。目前Git已經可以在windows下使用,主要方法有二:msysgit和Cygwin。Cygwin和Linux使用方法類似,Windows版本的Git提供了友好的GUI(圖形界面),安裝后很快可以上手,此處我們主要討論基於msysgit的Git安裝和使用。
TortoiseGit是TortoiseSVN的Git版本,TortoiseGit用於遷移TortoiseSVN到TortoiseGit。一直以來Git在Windows平台沒有好用GUI客戶端,現在TortoiseGit的出現給Windows開發者帶來福音。我們將在64位win7操作系統上安裝Git,並使用GUI界面,則需同時安裝msysGit和TortoiseGit。
安裝步驟
1. 安裝包下載
安裝包的下載,常用的有兩種方式。
(1). 百度直接搜索關鍵詞“Git”,在彈出的結果中,通過百度軟件中心下載,截圖如下所示。這種方法有一個缺點,就是安裝包不是最新的。如果圖省事的話,可以采取這種方法。
(2). 官網下載。網址為:https://git-scm.com/download。截圖如下所示。點擊“Downloads for Windows”按鈕,便可跳轉到下載鏈接,完成下載。
2. Git安裝
這里,我以Git 2.8.1 版本安裝包為例,進行安裝步驟講解。(因為這一版本是目前公司里用的最多的穩定版本)
1. 雙擊安裝包。截圖如下所示。
點擊下一步。
3、配置安裝組件
默認即可,點擊“Next。默認已經都幫我們否選上了。包括創建桌面快捷方式、Git Bash、Git GUi、已經目錄和后綴關聯等。
可勾選:On the Desktop,這樣,會自動在桌面生成Git的快捷方式。
可不勾選:Git GUI Here。目前,我都是使用Git Bash來進行操作。使用Git GUI,確實可以得到更好的UI體驗,不過,個人認為會減低效率。並且,初學者,還是先搞懂Git的常用指令,之后,再使用Git GUI才會有更好的理解。
在“Adjusting your PATH environment”選項中,默認即可。點擊“Next”。
這個步驟最好選擇第二項“Use Git from the Windows Command Prompt”, 這樣在Windows的命令行cmd中也可以運行git命令了。這樣會對以后的一些操作帶來方便。
配置行結束標記,保持默認“Checkout Windows-style, commit Unix-style line endings”。
在終端模擬器選擇頁面,默認即可,配置后Git Gash的終端比較易用。然后點擊“Next”。
最后配置Git額外選擇默認即可。然后點擊“Install”開始安裝。如果之前安裝過舊版本,會先卸載然后再安裝新版本。
安裝完成,默認點"Finish"即可。這樣會在瀏覽器打開新版本的信息。
安裝Git完成之后,會在桌面創建Git Bash快捷方式,在任意目錄下右擊鼠標可以找打Git Bash Here的選項。打開Git客戶端界面,輸入git。
lenovo@LAPTOP-LG72BB3R MINGW64 / $ git usage: git [--version] [--help] [-C <path>] [-c name=value] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p | --paginate | --no-pager] [--no-replace-objects] [--bare] [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] <command> [<args>] These are common Git commands used in various situations: start a working area (see also: git help tutorial) clone Clone a repository into a new directory init Create an empty Git repository or reinitialize an existing one work on the current change (see also: git help everyday) add Add file contents to the index mv Move or rename a file, a directory, or a symlink reset Reset current HEAD to the specified state rm Remove files from the working tree and from the index examine the history and state (see also: git help revisions) bisect Use binary search to find the commit that introduced a bug grep Print lines matching a pattern log Show commit logs show Show various types of objects status Show the working tree status grow, mark and tweak your common history branch List, create, or delete branches checkout Switch branches or restore working tree files commit Record changes to the repository diff Show changes between commits, commit and working tree, etc merge Join two or more development histories together rebase Reapply commits on top of another base tip tag Create, list, delete or verify a tag object signed with GPG collaborate (see also: git help workflows) fetch Download objects and refs from another repository pull Fetch from and integrate with another repository or a local branch push Update remote refs along with associated objects 'git help -a' and 'git help -g' list available subcommands and some concept guides. See 'git help <command>' or 'git help <concept>' to read about a specific subcommand or concept. lenovo@LAPTOP-LG72BB3R MINGW64 / $ pwd / lenovo@LAPTOP-LG72BB3R MINGW64 / $ ls bin/ cmd/ dev/ etc/ git-bash.exe* git-cmd.exe* LICENSE.txt mingw64/ proc/ ReleaseNotes.html tmp/ unins000.dat unins000.exe* unins000.msg usr/ lenovo@LAPTOP-LG72BB3R MINGW64 / $
我們可以開始學習Git了。
如果按照前面的步驟安裝下來,那么 git 程序所在的路徑已經添加到系統 PATH 中(path就相當於系統自動查找路徑列表),所以可以直接在任意路徑的 cmd 下執行 git 命令。 如果沒有添加,則需要 cd 切換到Git所在的 bin 目錄下,才能執行 git 命令。
Git學習系列之Windows上安裝Git之后的一些配置(圖文詳解)
擴展
Git學習系列之Debian或Ubuntu上安裝Git詳細步驟(圖文詳解)
Git學習系列之CentOS上安裝Git詳細步驟(圖文詳解)
同時,大家可以關注我的個人博客:
http://www.cnblogs.com/zlslch/ 和 http://www.cnblogs.com/lchzls/ http://www.cnblogs.com/sunnyDream/
詳情請見:http://www.cnblogs.com/zlslch/p/7473861.html
人生苦短,我願分享。本公眾號將秉持活到老學到老學習無休止的交流分享開源精神,匯聚於互聯網和個人學習工作的精華干貨知識,一切來於互聯網,反饋回互聯網。
目前研究領域:大數據、機器學習、深度學習、人工智能、數據挖掘、數據分析。 語言涉及:Java、Scala、Python、Shell、Linux等 。同時還涉及平常所使用的手機、電腦和互聯網上的使用技巧、問題和實用軟件。 只要你一直關注和呆在群里,每天必須有收獲
對應本平台的討論和答疑QQ群:大數據和人工智能躺過的坑(總群)(161156071)