打印

git安装

[复制链接]
1231|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
keer_zu|  楼主 | 2015-4-10 15:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
GIT, ST, AN, se, TI
How To Install Git on a CentOS 6.4 VPS


Introduction
Git is an open source, distributed version control system developed by Linus Torvalds, the creator of Linux. It features trivial branching and merging, the ability to manage multiple remote repositories for a single project, and truly distributed development.

Although git is wonderful at managing large, complex projects with perhaps hundreds or thousands of contributors, it can also work extremely well for small projects with one person or a small team. This flexibility makes it a great choice for implementing version and source control for software projects of any size.

In this article, we will cover how to install git on a CentOS 6.4 server using yum, the CentOS package manager. We will then show how to install git from source in case you would like to benefit from the latest improvements.


How To Install Git Using Yum
As is the case with most Linux distributions, git is available from CentOS's default repositories. We can install the package maintainer's most recent version with:

sudo yum install git
You will have to type "y" to confirm the installation. Afterwards, git will be installed and ready to use.


How To Install Git from Source on CentOS
If you want the most recent version of git, you are better off downloading the most recent version from source and compiling from there.

The version in the CentOS repositories as of this writing is 1.7.1, while the latest version of git is 1.8.4, which is a significant difference.

First, we need to download compilation tools for CentOS using the following command:

sudo yum groupinstall "Development Tools"
This will install the make tools and compilers needed to transform source code into binary executables.

Once this is complete, we will need to install some extra dependencies that git needs either to build or run:

sudo yum install zlib-devel perl-ExtUtils-MakeMaker asciidoc xmlto openssl-devel
Once these are installed, you can obtain the latest version of git from the code hosted on github.com:

cd ~wget -O git.zip https://github.com/git/git/archive/master.zip
Unzip the archive and change into the project directory:

unzip git.zipcd git-master
We can figure the package, build the executables and documentation, and then install it with the following set of commands:

make configure./configure --prefix=/usr/localmake all docsudo make install install-doc install-html
To update git at a later date, you can actually use git! Clone the git repository on github into a new directory and then build and install it, as before:

git clone git://github.com/git/git
How To Set Up Git
When you commit changes with git, it embeds your name and email address into the commit message in order to easily track changes.

If we do not configure this information ourselves, git may try to guess these values (probably incorrectly) by using your Linux username and hostname.

Give git the values you wish to use for these parameters with these commands:

git config --global user.name "Your Name Here"git config --global user.email "your_email@example.com"
The configuration changes will be stored in a file in your home directory. You can see them with a normal text editor:

nano ~/.gitconfig[user] name = Your Name Here email = your_email@example.com
You can also view this information by querying git itself for the current configuration settings:

git config --listuser.name=Your Name Hereuser.email=your_email@example.com
As mentioned earlier, if you forget to set up these steps, git may try to fill in these values automatically:

[master 0d9d21d] initial project version Committer: root Your name and email address were configured automatically basedon 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 you@example.comAfter doing this, you may fix the identity used for this commit with: git commit --amend --reset-author
Depending on your version of git, it may fail entirely:

git commit*** Please tell me who you are.Run git config --global user.email "you@example.com" git config --global user.name "Your Name"to set your account's default identity.Omit --global to set the identity only in this repository.fatal: empty ident name (for ) not allowed
As you can see, git is very good about telling you exactly what you should be doing.


Conclusion
You now have git installed and can start learning some basic usage. We have a few tutorials that may be good to look at:

How To Use Git Effectively

How To Use Git Branches

Git is a tool that becomes immediately useful with a basic understanding, and continues to offer advantages as your knowledge grows.

By Justin Ellingwood Tags: Git Distribution: CentOS

相关帖子

沙发
keer_zu|  楼主 | 2015-4-10 15:16 | 只看该作者
如果编译过程有报下面错误:

Git source code to download and install (CentOS)
1 read INSTALL files
$ make configure ;# as yourself
$ ./configure --prefix=/usr ;# as yourself
$ make all doc ;# as yourself
# make install install-doc install-html;# as root
2 the executive make configure
3 execution/configure --prefix=/usr
4 make all doc
/bin/sh: line 1: asciidoc: command not found
make[1]: *** [git-add.html] Error 127
make[1]: Leaving directory `/root/src/git/Documentation'
make: *** [doc] Error 2
Need to install asciidoc
Installing asciidoc 4.1:
To the official website to download asciidoc
http://sourceforge.net/projects/asciidoc/
cp asciidoc-8.5.2.tar.gz /root/src
cd /root/src
tar xvfz asciidoc-8.5.2.tar.gz
cd asciidoc-8.5.2
./configure
sudo make install
Then install the GIT
cd /root/src/git
make all doc
Wait wait, appeared again:
/bin/sh: line 1: xmlto: command not found
make[1]: *** [git-add.1] Error 127
make[1]: Leaving directory `/root/src/git/Documentation'
make: *** [doc] Error 2
Installing XMLto 4.2
yum install xmlto
Then install the GIT
cd /root/src/git
make all doc
Wait wait, make a lot of mistakes
I/O error : Attempt to load network entity
/root/src/git/Documentation/gitglossary.xml:2: warning: failed to load external entity ""
D DocBook XML V4.5//EN" ""
But in the end is through the.
8 make install install-doc install-html
The smooth implementation of the new version, have a look
[root@seti ~]# git --version
git version 1.7.1.575.gf526

使用特权

评论回复
板凳
yinhaix| | 2015-6-9 17:14 | 只看该作者

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1349

主题

12425

帖子

53

粉丝