CentOS中Git客户端的安装和基础配置教程

家电修理 2023-07-16 19:16www.caominkang.com电器维修

安装
目前的项目使用了GIT来进行版本管理,所以学习一下GIT的安装也是应该的了。本文介绍的是编译安装git1.9.0。虽然现在已经到2.6了。
所有命令请在root下进行。
第一步,安装依赖包。
在开始编译安装git之前,应该安装好必要的依赖包,省得在安装过程中出现各种问题。

复制代码代码如下:
#yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel g perl-ExtUtils-MakeMaker

第二步,下载并编译git。
你可以从kernel.上下载自己需要的版本,或者直接像我这样下载1.9.0版本。
切换到src目录,下载并解压git源码。

复制代码代码如下:
#cd /usr/src
get https://.kernel./pub/softare/scm/git/git-1.9.0.tar.gz
tar xzf git-1.9.0.tar.gz

进入到解压出的git目录,执行编译。

复制代码代码如下:
#cd git-1.9.0
# make prefix=/usr/local/git all
# make prefix=/usr/local/git install
# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
# source /etc/bashrc

第三步,完成。
现在你已经成功安装好了git,可以执行以下命令查看git版本。

复制代码代码如下:
# git --version

现在的fedora22中已经自带了git2.4以上的版本。

简单配置
我们生成公钥并复制到服务器上

复制代码代码如下:
[root@test ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in hich to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
48:3c:22:76:02:f1:a2:e5:27:22:cb:4f:a7:a0:98:9d root@test.
[root@test ~]# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIAAAQEArmgNAca77BKzXl6BP11fdaclAoWfW+x4kPDZMPj1zFoML9JfOAS7DGY9quLMitfg5+U7zP/egPmAhSKCECubmodzMuRSkJGgKCt1SlctRNDRN3OIvrecAtdZfDcBaWKLjaVzGPmheLhr6HzfqeZU09Ccis4yK3RMip2f+K1ZZVIOKUmL4AVFl9dqtxnQ4HlW61PUxvM/ug2M68Z0jQk5DVG85+dvGqX1qr5YABD1NX5Jz6aUbVVx7yyoORENxu6SK83GI/V7eOkrvBMDh9nDdvDhPhuhBDSfE+Xi92hPJPKdNroF1vx8HMvpHME20MmjSavPrz+B18MQ== root@test.

下面我们复制id_rsa.pub里的公钥到服务器的authorized_keys文件中。

复制代码代码如下:
[root@git ~]# su git
bash-3.2$ cd
bash-3.2$ vim .ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIAAAQEAMU4FKB6NRc3XSoIunWsdvVVuSoncbVb5Al6lB3cisBVd++YmJFhqkITNGrO5sycROs9+Fbjgd6oBSzNuaBtCIbNNsEyM/henTl2euI3XsnJQ/ITr6c/q0P3WoGl4E2QFQ2kZqs+1eDC0CgHcBrqvFv1Jr414sVYK9lfZIF+jDdtaBOrSJuq1Agx9pGUFUEB4tQfkXxsWm/MvOmKAVvduKDE1eenUEL9zzyeELPcSXLe3NOoTjZhkX6EEXxQR1ZiZRFyLpfM4qopZ10to2KIUyVtz6hx6V3cg7kn40lYVW0EAMAT9dVldcRUI+kJzJSKUTKDVSY3/+Q== root@CHENMINGQIAN
ssh-rsa AAAAB3NzaC1yc2EAAAABIAAAQEAsmmJuR+KhRSpdSirCiL30RA8WbfgicY1z7itWVnKHJW6hTuJFhzruY59FilVjJR1hbQBluP9JnK3XPSK9PSg+biJ2iQRa39rXck35r+trVOLyNbPyfKVRfOemD8YuykMlyr5JeW8gZjsHEuLnJ8//RiCiYzd3RT/SSUQ4yaDoIIWkz3eUSL09xoCRZFBsAp+S/LD3vx2MN+FNOHvqcE+yK3oRNIqjWLoKE0e5TRnqNgrPQ95PJYB3XPUulzaeMsWPZs7jIUMl/5yEqSgAkioa8SVMOsikYJG/erv99NNVgFmpCBIiWqKEGkNrIpYzLLHDSYQ4g5Gbci/RZ54Q== Administrator@WIN2003X323
ssh-rsa AAAAB3NzaC1yc2EAAAABIAAAQEA6NUHeNNi+PC6KlrcJrXXDmKxRMmgHIPp79sgX6zqfdSlmNj7rBPQeyEKS9Wg8yI6jd8aG2jsUx99Vjti2VK2vEXKkRHxID7ri69gE71RfDtv6ekafnzLo14J8hAp0spMk+N3EAQRYDmcYo1mnm/jMBedGrHj4NJQ1vYy1hVtJasGMSzjcMrlz9qvaluWnQ5tQjKFQVVKsRRRzs8qTvzVhLJt4NQ+CAN45tqfsRuf58Uba9QNK7/6xSUiIKXQiILz8PMGJ3MnlV+eN3x2aeztdevxu9plggtG05SMmd8GNVzXrN1IaxXSvz0UjQ2kygu7aCqO8AZWH49rou== leo@LEO-PC
ssh-rsa AAAAB3NzaC1yc2EAAAABIAAAQEArmgNAca77BKzXl6BP11fdaclAoWfW+x4kPDZMPj1zFoML9JfOAS7DGY9quLMitfg5+U7zP/egPmAhSKCECubmodzMuRSkJGgKCt1SlctRNDRN3OIvrecAtdZfDcBaWKLjaVzGPmheLhr6HzfqeZU09Ccis4yK3RMip2f+K1ZZVIOKUmL4AVFl9dqtxnQ4HlW61PUxvM/ug2M68Z0jQk5DVG85+dvGqX1qr5YABD1NX5Jz6aUbVVx7yyoORENxu6SK83GI/V7eOkrvBMDh9nDdvDhPhuhBDSfE+Xi92hPJPKdNroF1vx8HMvpHME20MmjSavPrz+B18MQ== root@test.

下面我们clone一个仓库到本地的目录中。

复制代码代码如下:
[root@test ~]# cd /data/dev
[root@test dev]# git clone git@git.jjhh.:/data/git/project.git
Cloning into 'project'...
The authenticity of host 'git.jjhh. (114.112.173.150)' can't be established.
RSA key fingerprint is ca:ec:a2:7e:e6:89:ca:19:d3:93:7f:4b:c3:c0:c7:fd.
Are you sure you ant to continue connecting (yes/no)? yes
Warning: Permanently added 'git.jjhh.,114.112.173.150' (RSA) to the list of knon hosts.
remote: Counting objects: 50, done.
remote: Compressing objects: 100% (42/42), done.
remote: Total 50 (delta 21), reused 0 (delta 0)
Receiving objects: 100% (50/50), 4.02 KiB, done.
Resolving deltas: 100% (21/21), done.
[root@test dev]# ls
project
[root@test dev]# cd project/
[root@test project]# ls
index.html

好了,到这里我们的git客户端到这里就全部安装完成了。

Copyright © 2016-2025 www.caominkang.com 曹敏电脑维修网 版权所有 Power by