1.1-Git 安裝:
Git 工具分類:
命令行:
Bash、Cmd、Power Shell,等。
GUI:
Git GUI、Github Desktop,等。
IDE集成:
Visual Studio、Eclipse、IntelliJ IDE,等。
注:
實際上應該是分為兩大類,一類是命令行,一類是GUI,IDE集成類的工具也是帶圖形化界面的。
Git 工具下載及安裝:
下載地址:https://git-scm.com/
雙擊打開后,一直點擊Next(下一步)即可。
1.2-Git工具簡單配置:
設置 Git Bash 環境:
點擊命令行窗口左上角圖標,打開選項。
選項中的第一項Lookes,里面的第一個就是Colours(顏色),其中Cursor就是光標的顏色,默認是白色,將其改成綠色。
光標默認的形狀是Line(直線),將其改成Block(塊狀),然后默認是Blinking(閃爍的),將其去掉,最后點擊Apply。
接著打開選項中的第二項Text,修改命令行窗口的文字大小,默認是9號,將其修改成12號,點擊save保存。
1.3-Bash命令初體驗:
cd:
是 change directory
是這兩個單詞的首字母,表示更改目錄。
Administrator@PC-20150529TMSZ MINGW64 /g/ceshi/hello
$ cd /g/ceshi/
Administrator@PC-20150529TMSZ MINGW64 /g/ceshi
mkdir:
是 make directory
這個單詞的縮寫,表示創建目錄。
Administrator@PC-20150529TMSZ MINGW64 /g/ceshi
$ mkdir hello
pwd:
是 print working directory
這三個單詞的首字母,表示打印當前工作目錄。
Administrator@PC-20150529TMSZ MINGW64 /g/ceshi
$ pwd
/g/ceshi
mv:
是 move
這個單詞的縮寫,表示移動文件。
Administrator@PC-20150529TMSZ MINGW64 /g/ceshi/hello
$ mv 2.txt ../2.txt #將 2.txt 移動到 上一級文件夾中
cp:
是 copy
這個單詞的縮寫,表示復制文件或目錄。
Administrator@PC-20150529TMSZ MINGW64 /g/ceshi/hello
$ cp 1.txt 2.txt #將 1.txt 里的內容復制到 2.txt 里
Administrator@PC-20150529TMSZ MINGW64 /g/ceshi/hello
$ mv 1.txt a.txt #如果在 同一文件夾下 就是修改文件名
rm:
是 remove
這個單詞的縮寫,表示刪除文件。
Administrator@PC-20150529TMSZ MINGW64 /g/ceshi/hello
$ rm a.txt
echo:
表示在顯示器上打印一段文字。
Administrator@PC-20150529TMSZ MINGW64 /g/ceshi/hello
$ echo "hello world"
hello world
Administrator@PC-20150529TMSZ MINGW64 /g/ceshi/hello
$ echo "hello world" > 1.txt #將打印的信息,放到 1.txt 這個文件里
cat:
表示查看文件內容。
Administrator@PC-20150529TMSZ MINGW64 /g/ceshi/hello
$ cat 1.txt #查看 1.txt 文件中的內容
hello world
ls:
表示列出當前目錄下的文件。
Administrator@PC-20150529TMSZ MINGW64 /g/ceshi
$ ls
2.txt hello/
1.4-設置 Git 參數:
顯示當前的 git 配置:
git config --list
設置提交倉庫時的用戶名信息
git config --global user.name "guokev"
設置提交倉庫時的郵箱信息:
git config --global user.email "123456@qq.com"
注:上面那些信息就是配置文件,都在文件里存著,在主目錄下的 .gitconfig
這個文件里。
可以通過vim編輯這個文件:
Administrator@PC-20150529TMSZ MINGW64 ~
$ vim .gitconfig
驗證安裝是否成功:
Administrator@PC-20150529TMSZ MINGW64 ~
$ git --version
git version 2.12.2.windows.2