github在liunx上的搭建
清屏:ctrl+l
1 在linux下安装git
yum -y install git
查看版本 git --version
4 设置git的用户名和邮箱地址
git config --global user.name "savadika"
git config --global user.email "ylf8708@126.com"
2 生成ssh的key文件
ssh-keygen -t rsa -C "ylf8708@126.com"
此时会出来两个确认:
enter file which to save the key(/root/.ssh/id_rsa): 点回车
enter the passphrase(empty for no passphrase): 意思是确认密码,点回车
enter same passphrase again: 再次确认密码,点回车
然后找到/root/.ssh 下面的文件,找到id_rsa.pub(公钥文件),复制其中的key
3 然后打开网页上的github,在github上填写key,见图
此时进入/root 下可以看到这个y文件和y.pub文件,打开y.pub(公钥密匙),看到内容为很长一串文件,copy下来:
copy的办法:使用ssh终端连接登录到linux,然后ctrl+c,需要的地方再ctrl+v;
4 测试连接,OK
[root@localhost .ssh]# ssh -T git@github.com
The authenticity of host 'github.com (192.30.252.129)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.
Hi savadika! You've successfully authenticated, but GitHub does not provide shell access.
[root@localhost .ssh]#
到目前为止,git已经安装成功,先来学习本地仓库
在/tmp下新建gitpro文件夹,进入gitpro,然后建立本地仓库
初始化命令: git init
利用ls -ah 命令可以看到这个.git的隐藏文件,这个就是仓库
[root@localhost gitpro]# git init
Initialized empty Git repository in /tmp/gitpro/.git/
[root@localhost gitpro]# ls -ah
. .. .git
[root@localhost gitpro]# cd .git/
[root@localhost .git]# ls
branches config description HEAD hooks info objects refs
[root@localhost .git]#
在 gitpro 文件夹下,注意:不要进.git文件
新建readme.txt,然后随便写点内容,保存
提交到git仓库,两步
git add readme.txt
git commit -m "create a txt"
修改readme.txt 后,就可以查看状态了,
git status 显示git状态
[root@localhost gitpro]# git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: readme.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
如果你要看具体修改了什么
git diff
[root@localhost gitpro]# git diff
diff --git a/readme.txt b/readme.txt
index 69f9b26..d64807a 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,2 +1,2 @@
-hello ,this is a new txt
+hello ,this is a new distrube txt
let us start
[root@localhost gitpro]#
总结下,就是三步:1 修改文件 2 git add 文件 3 git commit -m "备注"
如果需要看日志的话
git log
[root@localhost gitpro]# git log
commit adedce902c5bf1f57cedd4f971b2ce98f6b86509
Author: savadika <ylf8708@126.com>
Date: Tue Jan 5 17:18:07 2016 +0800
this is a third work
commit 55ac577532aa97fbb4295303a664a5ad7505e540
Author: savadika <ylf8708@126.com>
Date: Tue Jan 5 17:14:51 2016 +0800
add distribu
commit c80957880f0618ba0f682a94498d50e8afe5a674
Author: savadika <ylf8708@126.com>
Date: Tue Jan 5 17:02:35 2016 +0800
create a txt
好了,现在我们启动时光穿梭机,准备把readme.txt回退到上一个版本,也就是“add distributed”的那个版本,怎么做呢?
首先,Git必须知道当前版本是哪个版本,在Git中,用HEAD表示当前版本,也就是最新的提交3628164...882e1e0(注意我的提交ID和你的肯定不一样),
上一个版本就是HEAD^,上上一个版本就是HEAD^^,当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100。
[root@localhost gitpro]# git reset --hard HEAD^
HEAD is now at 55ac577 add distribu
也就是说,此时已经退回到了55ac57这个版本了
那万一回退错了,想撤销呢?先要保证这个版本号你记得
使用git reset --hard adedce(想回退过去的那个版本的前6位)
万一实在忘记了呢,没事,还是有后悔药
git reflog,能够看到那个版本的东西
[root@localhost gitpro]# git reflog
adedce9 HEAD@{0}: adedce: updating HEAD
55ac577 HEAD@{1}: HEAD^: updating HEAD
adedce9 HEAD@{2}: commit: this is a third work
55ac577 HEAD@{3}: commit: add distribu
c809578 HEAD@{4}: commit (initial): create a txt
现在,你又理解了Git是如何跟踪修改的,每次修改,如果不add到暂存区,那就不会加入到commit中。
关于删除:
在工作区的删除回滚:
git checkout --readme.txt
已经add,后怎么删除全部文件
git rm test.txt
git checkout --readme.txt
测试远程仓库
上传:
问题1 :出现已有origin仓库出错
1 删除原有的origin仓库(有出现错误的时候做这个操作)
git remote rm origin
问题2 :直接在远程仓库里面修改后再推送报错,因为已经修改过,所以需要先pull到本地
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.
解决:[root@localhost gitpro]# git pull 将github仓库上的文件覆盖到本地
然后再
[root@localhost gitpro]# git push origin master
2 在web上新建一个项目用来测试推送,地址为:git@github.com:savadika/gitpro.git
推送上去:
[root@localhost gitpro]# git remote add origin git@github.com:savadika/gitpro.git //添加远程git仓库
[root@localhost gitpro]# git push -u origin master //第一次添加
$ git push origin master //以后添加
下载:
git clone https://github.com/yiiext/chart 或者使用ssh协议更快 git clone git@github.com:yiiext/chart
然后就能看到下载的这个软件了,可以进行查看等
oK.大工告成!

github在liunx上的搭建的更多相关文章
- <转>git,github在windows上的搭建
http://www.cnblogs.com/yixiaoyang/archive/2012/01/06/2314190.html Git在源码管理领域目前占很大的比重了,而且开源的项目很多都转到Gi ...
- 上一周,小白的我试着搭建了两个个人博客:在github和openshift上
上一周,突发奇想,想搭建个自己的博客. 由于是突发奇想,自然想先找免费的试试手.仔细搜索下,选定了目标Openshift和Github. Openshift 安装WordPress OpenShift ...
- 将 Hexo 个人博客同时部署到 GitHub 和 Coding 上
一.将个人博客托管到 GitHub 上 关于如何快速搭建自己的个人博客,如何完善自己的个人博客,什么是 GitHub ,如何将自己的博客代码托管到 GitHub 上面等等问题,我之前写过三篇文章已经做 ...
- 将`VuePress`建立的博客部署到GitHub或Gitee上
将VuePress建立的博客部署到GitHub或Gitee上 在上一篇中,我们详细介绍了如何利用VuePress搭建起个人博客系统,但这只是在本地debug启动的,接下来,我们把它部署到Github网 ...
- 在GitLab pages上快速搭建Jekyll博客
前一段时间将我的Jekyll静态博客从github pages镜像部署到了 zeit.co(现vercel)上了一份,最近偶然发现gitlab pages也不错,百度也会正常抓取,于是动手倒腾,将gi ...
- 在阿里云服务器(ECS)上从零开始搭建nginx服务器
本文介绍了如何在阿里云服务器上从零开始搭建nginx服务器.阿里云服务器(ECS)相信大家都不陌生,感兴趣的同学可以到http://www.aliyun.com/product/ecs去购买,或到体验 ...
- [转]Liunx上安装svn客户端
[转]Liunx上安装svn客户端 虽然说很简单的用yum install subversion就可以将svn安装到系统中,但是yum库中的版本实在是有点低——1.4.2.因此我选择以源码方式安装.安 ...
- WAMP Server助你在Windows上快速搭建PHP集成环境
WAMP Server助你在Windows上快速搭建PHP集成环境 原文地址 我想只要爬过几天网的同学都会知道PHP吧,异次元的新版本就是基于PHP的WordPress程序制造出来的,还有国内绝大部分 ...
- C#在局域网中连接Liunx上的MySql数据库
前期准备工作: 我所用的平台是VS2010和Ubuntu 14.04.3 LTS 一.由于MySql并没有集成在VS2010中所以要先安装MySQL Connector Net 6.9.8连接工具, ...
随机推荐
- surface pro 4 wifi掉线问题
更新你的无线网卡驱动到最新版本15.68.9032.47,重启.或者运行regedit修改注册表 HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\mr ...
- 使用Python写Windows Service服务程序
1.背景 如果你想用Python开发Windows程序,并让其开机启动等,就必须写成windows的服务程序Windows Service,用Python来做这个事情必须要借助第三方模块pywin32 ...
- ACM集训的第一题
对于一群NP(2<=NP<=10)个要互送礼物的朋友,郭铮鹏要确定每个人送出的钱比收到的多多少. 在这一个问题中,每个人都准备了一些钱来送礼物,而这些钱将会被平均分给那些将收到他的礼物的人 ...
- 学霸数据处理项目之数据处理网页以及后台以及C#代码部分开发者手册
写在前面,本文将详细介绍学霸数据处理项目中的数据处理网页与后台函数,以及c#代码中每一个方法的意义及其一些在运行方面需要注意的细节,供开发人员使用,开发人员在阅读相关方法说明时请参照相关代码,对于本文 ...
- C#获取网页的HTML码、下载网站图片、获取IP地址
1.根据URL请求获取页面HTML代码 /// <summary> /// 获取网页的HTML码 /// </summary> /// <param name=" ...
- JSP三大指令、七大动作、九大对象
<%---------------------- JSP三大指令 -----------------------------%><%-- 1. page: language impo ...
- php编写tcp服务器和客户端程序
这是我从别的地方看到的. 1.修改php.ini,打开extension=php_sockets.dll 2.客户端程序 SocketClient.php <?php set_time_limi ...
- 今年暑假不AC
"今年暑假不AC?""是的.""那你干什么呢?""看世界杯呀,笨蛋!""@#$%^&*%...&quo ...
- Leetcode: Range Addition
Assume you have an array of length n initialized with all 0's and are given k update operations. Eac ...
- Infinite V2 Release Note
游戏地址 PLAY 玩法说明 - WASD 控制角色移动 - 按下J键 进入攻击模式(WASD 可以继续移动) 更新内容 - 完成角色锁定目标后边移动边攻击 开发心得 状态机的设计 最初的设计很乱, ...