当前位置:首页 > 编程开发

CentOS7编译安装git并配置使用github

webgou9年前 (2018-01-17)编程开发157

 

一、编译安装git

CentOS7默认安装的git版本为1.8.3.1,而git官方的版本已经到2.2.0了,所以选择下载源码编译安装git

1.clone github上的git源码

$ git clone https://github.com/git/git.git

2.进入git目录进行配置及安装

1
2
3
4
5
$ cd git
$ autoconf
$ ./configure
$ make
$ make install

期间可能会提示缺少文件,是因为git的依赖包没有安装,缺什么装什么就好,或者直接
yum -y install curl curl-devel zlib-devel openssl-deve perl perl-devel cpio expat-devel gettext-deve

3.查看版本

1
2
$ git --version
git version 1.8.3.1

竟然还是原来的版本而不是最新安装的2.2.0,那只能先把旧版本卸载了

1
2
3
$ rpm -q git
git-1.8.3.1-4.el7.x86_64
$ sudo rpm -e --nodeps git-1.8.3.1-4.el7.x86_64

 

然后执行
sudo ln -s /usr/local/bin/* /usr/bin/
再次查看git版本

1
2
$ git --version
git version 2.2.0.GIT

 

git版本已经是我们新安装的2.2.0了

4.设置自己的用户名和邮箱

命令行输入:(引号加不加无所谓)

1
2
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"

 

5.在本地创建仓库并初始化

1
2
3
$ mkdir test
$ cd test
$ git init

初始化空的 Git 版本库于 /home/username/github/test/.git/
至此git安装完成

二、使用github

1.注册github账号

我这里创建了一个账号:SinalVee,并创建了一个Test仓库用于测试

2.用ssh-kengen生成公钥

$ ssh-keygen -t rsa -C xxx@xxx.com
xxx@xxx.com为你的邮箱地址

设定存放目录和密码后在github设置中找到SSH Keys,选择Add SSH Key,设置名称并把*/.ssh/id_rsa.pub的文件内容粘贴进去

3.测试是否成功

$ ssh -T git@github.com
出现下面的信息并提示验证私钥则成功,输入密码解锁私钥

1
2
3
4
5
The authenticity of host 'github.com (192.30.252.130)' can't be established.
RSA key fingerprint is 16:27:ac:axxxxxxxxxxxxxxxxx:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.130' (RSA) to the list of known hosts.
Hi SinalVee! You've successfully authenticated, but GitHub does not provide shell access.

 

在本地任意目录新建同步文件夹

1
2
3
$ mkdir github
$ cd github
$ git clone git@github.com:SinalVee/Test(此处SinalVee为用户名,Test是你在github上创建的仓库)

 

1
2
3
4
5
6
正克隆到 'Test'...
Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hosts.
remote: Counting objects: 6, done.
remote: Total 6 (delta 0), reused 0 (delta 0)
接收对象中: 100% (6/6), 完成.
检查连接... 完成。

因为我很久之前就创建了这个Test仓库并测试过,所以这里共有6个objects(一共两个文件,之所以这里是6是因为Git跟踪并管理的是修改,而非文件)。

接下来测试以下上传

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ cd Test/
$ ls
README.md test.txt
$ touch hello.txt
$ vim hello.txt
你好,这是一个测试文件。
$ ls
hello.txt README.md test.txt
$ git add hello.txt
$ git commit -m "add file hello.txt"
[master 0e4004c] add file hello.txt
1 file changed, 1 insertion(+)
create mode 100644 hello.txt
$ git push
对象计数中: 3, 完成.
Delta compression using up to 4 threads.
压缩对象中: 100% (2/2), 完成.
写入对象中: 100% (3/3), 354 bytes | 0 bytes/s, 完成.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:sinalvee/Test
984cabc..0e4004c master -> master

 

在github的网页上刷新一下仓库,发现hello.txt已经上传成功了,至此我们的github已经配置成功,并可以使用了。

github的使用这里不多赘述了。

 

来源:https://sinalvee.github.io/2014/12/26/centos7-git-github/

扫描二维码推送至手机访问。

版权声明:本文由知了博客发布,如需转载请注明出处。

本文链接:https://www.webgou.info/?id=619

分享给朋友:

“CentOS7编译安装git并配置使用github” 的相关文章

虚幻4(ue4)引擎加密pak解包教程(初学者向x64源码逆向)

 前言  遇到了喜欢的游戏,想提取壁纸,于是找quickbms等虚幻4引擎解包工具。无奈游戏加密,无法解包。不知密钥情况下,也没在网上找到现成的加密pak解包工具。想到Unreal4已经开源,就尝试着自己找一下密钥,也算是对照源码的x64逆向分析调试。以前接触的Olly…

android ndk "5039: Operation timed out."解决办法

在调试C/C++代码时,需执行: 1.adb forward tcp:5039 tcp:5039 2.ndk-gdb-eclipse --force --start 参考: ndk-gdb关联eclipse设置方法 Using cgdb with ndk-debug (and cgdb tuto…

ATL处理函数跳转的思考

今天,分析MFC与WTL的消息映射,比较难理解的有下面两点: 1.MFC,AfxCbtFilterHook转到AfxWndProc, 2.WTL(ATL),CWndProcThunk把窗口指针跳转到WindowProc,并把hWnd改成窗口指针.…

iOS开发中常见的语句@synthesize obj=_obj的意义详解

  我们在进行iOS开发时,经常会在类的声明部分看见类似于@synthesize window=_window; 的语句,那么,这个window是什么,_ window又是什么,两个东西分别怎么用,这是一个比较基本的问题,也关乎我们理解Objective-C中对类、类的…

[转]Unity琐碎(3) UGUI 图文混排解决方案和优化

 感觉使用Unity之后总能看到各种各样解决混排的方案,只能说明Unity不够体恤下情啊。这篇文章主要讲一下个人在使用过程中方案选择和优化过程,已做记录。顺便提下,开源很多意味着坑,还是要开实际需求。1. 方案选择1 TextMeshProUnity 最近公布收购了TextMeshPro并…

实用Android开发工具和资源精选

\ 本文介绍了20个关于Android应用程序开发的实用工具资源,供大家分享。     在google、开源平台,和来自移动电话制造商HTC,Samsung和Sony Ericsson的支持下,Android平台在市场占有率上相比去年取得的886%增长!如果我只看增长率…

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。