Ubuntu/LinuxMint/ElementaryOS使用PPA安装Git2.6.1

Git是一个免费、自由、开源的分布式版本控制系统,可以快速高效地处理大中小型项目。它是github的一个客户端。在这篇教程中,我将介绍如何在ubuntu,linuxmint和elementary OS上安装 git 2.6.1。2.6.1是一个稳定版本,于2015年9月28日发布。git是最流行的版本控制系统之一。

安装git的命令

添加GIT的官方PPA

sudo add-apt-repository ppa:git-core/ppa

更新本地的软件包索引

sudo apt-get update

安装git 2.6.0

sudo apt-get install git

当然,你也可以不使用PPA安装,直接输入sudo apt-get install git命令,但是ubuntu官方软件库的版本会比较旧,如果你要使用最新的版本,那么使用PPA的方式来安装。

设置git commit

安装好git后,我们需要做一点配置,让commit消息包含正确的信息。最简单的方法是使用 git config 命令。我们要提供名字和邮箱地址,因为git会将名字和邮箱地址嵌入到每一条commit消息中。

git config --global user.name "Your Name"

git config --global user.email "[email protected]"

我们可以使用下面的命令来查看所有的配置

git config --list

你也可以使用文件编辑器来修改配置文件

vi ~/.gitconfig

你可以设置其他的选项,名字和邮箱是必须要设置的。如果没有设置这一步,那么当你commit到git时,你会看到下面的警告信息

[master 0d9d21d] initial project version
 Committer: root 
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
 git config --global user.email [email protected]
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
为这篇文章评分
[Total: 0 Average: 0]

Leave a Reply

Your email address will not be published.

The maximum upload file size: 2 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here