目錄準備
使用普通用戶執行一下即可。如wuyujin
。(新建用戶命令:useradd wuyujin
)
- 下載
wget https://codeload.github.com/git/git/zip/master
更多版本見https://github.com/git/git
安裝文檔見https://github.com/git/git/blob/master/INSTALL - 解壓
unzip git-master.zip
- 進入目錄
cd cd git-master/
編譯安裝
- 編譯
make prefix=/usr all doc info
加的參數是爲了全局安裝,而非只爲當前用戶安裝。- 報錯:
fatal error: openssl/ssl.h: No such file or directory
安裝libssl-dev
- 報錯:
fatal error: zlib.h: No such file or directory
安裝zlib1g-dev
- 報錯:
fatal error: curl/curl.h: No such file or directory
安裝libcurl4-gnutls-dev
- 報錯:
fatal error: expat.h: No such file or directory
安裝libexpat1-dev
- 報錯:
重新執行make prefix=/usr all doc info
,輸出如下:
wuyujin@ubuntu18:~/Downloads/git-master$ make prefix=/usr all doc info ;# as yourself
SUBDIR git-gui
SUBDIR gitk-git
SUBDIR templates
make -C Documentation all
make[1]: Entering directory '/home/wuyujin/Downloads/git-master/Documentation'
make[2]: Entering directory '/home/wuyujin/Downloads/git-master'
make[2]: 'GIT-VERSION-FILE' is up to date.
make[2]: Leaving directory '/home/wuyujin/Downloads/git-master'
ASCIIDOC git-merge-index.html
/bin/sh: 2: asciidoc: Permission denied
Makefile:363: recipe for target 'git-merge-index.html' failed
make[1]: *** [git-merge-index.html] Error 127
make[1]: Leaving directory '/home/wuyujin/Downloads/git-master/Documentation'
Makefile:2503: recipe for target 'doc' failed
make: *** [doc] Error 2
wuyujin@ubuntu18:~/Downloads/git-master$
還是有兩個Error。
Makefile:363: recipe for target ‘git-merge-index.html’ failed
Makefile:2503: recipe for target ‘doc’ failed
不過要用的可執行程序大都已經有了。先用起來。等遇到問題再排查解決。
wuyujin@ubuntu18:~/Downloads/git-master$ which git
/usr/bin/git
wuyujin@ubuntu18:~/Downloads/git-master$ ll /usr/bin | grep git
-rwxr-xr-x 130 root root 17501168 2月 9 15:36 git*
-rwxr-xr-x 2 root root 162733 2月 9 15:36 git-cvsserver*
-rwxr-xr-x 1 root root 353477 2月 9 15:36 gitk*
-rwxr-xr-x 130 root root 17501168 2月 9 15:36 git-receive-pack*
-rwxr-xr-x 2 root root 10346728 2月 9 15:36 git-shell*
-rwxr-xr-x 130 root root 17501168 2月 9 15:36 git-upload-archive*
-rwxr-xr-x 130 root root 17501168 2月 9 15:36 git-upload-pack*
-rwxr-xr-x 1 root root 14200 4月 23 2016 sgitopnm*
wuyujin@ubuntu18:~/Downloads/git-master$
- 安裝
make install
使用測試
- 測試
git clone https://github.com/qin-ziqi/Chrome-SetupVPN-3.7.0.git
SetupVPN是一個瀏覽器插件,可用於**。 - 查看下載內容
ll Chrome-SetupVPN-3.7.0/
wuyujin@ubuntu18:~/Downloads$ ll Chrome-SetupVPN-3.7.0/
total 48
drwxr-xr-x 9 wuyujin wuyujin 4096 2月 9 19:08 ./
drwxr-xr-x 8 wuyujin wuyujin 4096 2月 9 19:08 ../
drwxr-xr-x 3 wuyujin wuyujin 4096 2月 9 19:08 assets/
drwxr-xr-x 2 wuyujin wuyujin 4096 2月 9 19:08 fonts/
drwxr-xr-x 8 wuyujin wuyujin 4096 2月 9 19:08 .git/
drwxr-xr-x 3 wuyujin wuyujin 4096 2月 9 19:08 images/
drwxr-xr-x 2 wuyujin wuyujin 4096 2月 9 19:08 js/
-rw-r--r-- 1 wuyujin wuyujin 763 2月 9 19:08 manifest.json
-rw-r--r-- 1 wuyujin wuyujin 263 2月 9 19:08 popup.html
-rw-r--r-- 1 wuyujin wuyujin 981 2月 9 19:08 README.md
drwxr-xr-x 2 wuyujin wuyujin 4096 2月 9 19:08 styles/
drwxr-xr-x 2 wuyujin wuyujin 4096 2月 9 19:08 views/
wuyujin@ubuntu18:~/Downloads$
- 更多git命令見官網
使用包管理工具安裝、卸載、查詢安裝位置
- 安裝
sudo add-apt-repository ppa:git-core/ppa # 添加源
sudo apt update # 更新源
sudo apt install git # 安裝git
- 卸載
sudo apt-get remove git --purge
- 查詢安裝位置
dpkg -L git
- 查詢常用命令的位置
which git
wuyujin@ubuntu18:~$ which git
/usr/bin/git
wuyujin@ubuntu18:~$ ll /usr/bin | grep git
-rwxr-xr-x 1 root root 3068336 1月 14 14:44 git*
lrwxrwxrwx 1 root root 3 1月 14 14:44 git-receive-pack -> git*
-rwxr-xr-x 1 root root 1752640 1月 14 14:44 git-shell*
lrwxrwxrwx 1 root root 3 1月 14 14:44 git-upload-archive -> git*
lrwxrwxrwx 1 root root 3 1月 14 14:44 git-upload-pack -> git*
-rwxr-xr-x 1 root root 14200 4月 23 2016 sgitopnm*
wuyujin@ubuntu18:~$