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连接工具, ...
随机推荐
- Linux图形&命令行界面切换
1.实时切换 1.1 命令行->图形 startx 1.2 图形->命令行 Ctrl+Alt+F1--F6 2.启动默认 2.1 启动进入命令行 修改/etc/inittab文件 &quo ...
- 如何在Eclipse中查看JDK以及JAVA框架的源码(转载)
原文链接:http://www.cnblogs.com/outlooking/p/5243415.html 设置步骤如下: 1.点 “window”-> "Preferences&qu ...
- Python学习【第十一篇】模块(1)
模块 模块让你能够有逻辑地组织你的Python代码段. 把相关的代码分配到一个模块里能让你的代码更好用,更易懂. 模块也是Python对象,具有随机的名字属性用来绑定或引用. 简单地说,模块就是一个保 ...
- rplidar & hector slam without odometry
接上一篇:1.rplidar测试 方式一:测试使用rplidar A2跑一下手持的hector slam,参考文章:用hector mapping构建地图 但是roslaunch exbotxi_br ...
- nodejs 的ajax获取数据express
var request = require('request'); request('https://api.weixin.qq.com/cgi-bin/ticket/getticket?access ...
- echarts基础 handleIcon 设置
1.自己引入echarts库 2.找到代码中dataZoom中的handleIcon ,看见对应的是"M0,0 v9.7h5 v-9.7h-5 Z",这是由svg画出来的图形,其中 ...
- ubuntu安装使用latex和texmaker--PC端
参考文档 据说中文文献可能不识别,可能用到的参考资料
- asp.net mvc 5 web api 关于Requested resource does not support options 问题
1.用visual studio 2015 建立一个 web api 应用程序.记住这是一个 web api 应用. 2.新建一个web api . 3.用C#访问,代码如下:[没有问题,返回正确] ...
- 在设置app icon时的问题
APP 运行时遇到 the app icon set named appicon did not have any applicable content 是应该考虑是icon可能偏大
- 第九章伪代码编程过程 The PseudoCode Programming Process
目录: 1.创建类和子程序的步骤概述 2.伪代码 3.通过伪代码编程过程创建子程序 4.伪代码编程过程的替代方案 一.创建类和子程序的步骤概述 (1)创建一个类的步骤 1.创建类的总体设计 2.创建类 ...