Ubuntu下配置git

来源:互联网 发布:我的世界 知乎 编辑:程序博客网 时间:2024/06/06 01:02

最近在使用vscode的git功能,自己用的系统是Ubuntu16.04,下面总结一下在Ubuntu下如何配置git。

一、安装环境依赖:

如果你想从源码安装 Git,需要安装 Git 依赖的库:curl、zlib、openssl、expat,还有libiconv。 如果你的系统上有 yum (如 Fedora)或者 apt-get(如基于 Debian 的系统),可以使用以下命令之一来安装最小化的依赖包来编译和安装 Git 的二进制版:

 $ sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev $ sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev

为了能够添加更多格式的文档(如 doc, html, info),你需要安装以下的依赖包:

$ sudo apt-get install asciidoc xmlto docbook2x

二、git源码下载地址:

1、从 Kernel.org 网站获取,网址为 https://www.kernel.org/pub/software/scm/git
2、从 GitHub 网站上的镜像来获得,网址为 https://github.com/git/git/releases
Note:通常在 GitHub 上的是最新版本,但 kernel.org 上包含有文件下载签名,如果你想验证下载正确性的话会用到。用命令 sudo apt-get install git 是安装一个较旧的版本(一般在配置某些环境时这样做)

三、编译并安装:

我从github上下载的版本是git-2.13.0-rc2

  $ tar -zxf git-2.13.0-rc2.tar.gz  $ cd git-2.13.0-rc2  $ make configure  $ ./configure --prefix=/usr/local  $ make prefix=/usr/local all doc info  $ sudo make prefix=/usr/local install install-doc install-html

执行 make configure出现的错误:

douxiao@sunshine:~/git-2.13.0-rc2$ make configure     GEN configure/bin/sh: 1: autoconf: not foundMakefile:1937: recipe for target 'configure' failedmake: *** [configure] Error 127

解决办法:

sudo apt-get install dh-autoreconf

执行make prefix=/usr/local all doc出现的错误:

make[2]: Leaving directory '/home/douxiao/git-2.13.0-rc2'    ASCIIDOC git-sh-i18n--envsubst.html/bin/sh: 2: asciidoc: not foundMakefile:328: recipe for target 'git-sh-i18n--envsubst.html' failedmake[1]: *** [git-sh-i18n--envsubst.html] Error 127make[1]: Leaving directory '/home/douxiao/git-2.13.0-rc2/Documentation'Makefile:2113: recipe for target 'doc' failedmake: *** [doc] Error 2

解决办法:

sudo apt-get install asciidoc//这个可能要执行两次

其他可能遇到的错误及解决办法:

 http.h:6:23: fatal error: curl/curl.h: No such file or directory 解决方法:apt-get install libcurl4-gnutls-dev http-push.c:17:19: fatal error: expat.h: No such file or directory 解决方法:apt-get install libexpat1-dev * tclsh failed; using unoptimized loading MSGFMT    po/de.msg make: *** [po/de.msg] 错误 127 解决方法:apt-get install tk /bin/sh: 1: msgfmt: not found make: *** [po/build/locale/bg/LC_MESSAGES/git.mo] Error 127 解决方法:apt-get install gettext

四、完成后,可以使用 Git 来获取 Git 的升级:

 $ git clone git://git.kernel.org/pub/scm/git/git.git

五、查看git的历史版本:

git --version

五、常用的错误解决办法

https://github.com/Marslo/MyBlog/blob/master/Programming/Git/GitQ%26A.md

五、push时遇到的问题

git fatal: Unable to find remote helper for ‘https’
解决办法链接:
http://www.cnblogs.com/wowarsenal/p/4319002.html

参考:

http://blog.sina.com.cn/s/blog_68af3f090101h3so.html
https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git
http://xiaocainiaox.blog.51cto.com/4484443/1698634

0 0