文章目录
目录准备
使用普通用户执行一下即可。如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:~$