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连接工具, ...
随机推荐
- 去除magento多店铺URL地址中的“___from_store=”
magento 的多店铺功能,大多数情况下是根据语言来进行选择的,当添加了多店铺之后,一般情况下我们会选择开启添加store code到url地址中. Magento 自带的这种功能算是比较不错了,但 ...
- CSS之伪元素
1. :first-line 向元素的首行文本添加样式,不必关心首行是元素节点还是文本节点 <style> body,htm,div,p{ margin:0; padding:0; } d ...
- JMeter学习-026-JMeter 分布式(远程)参数化测试实例
以前文所述对文章详情的HTTP请求进行性能测试为例.日常实际场景中,不可能所有的人都在同时访问一篇文章,而是多人访问不同的文章,因而需要对文章编号进行参数化,以更好的模拟日常的性能测试场景.同时,因文 ...
- JMeter学习-022-JMeter 分布式测试(性能测试大并发、远程启动解决方案)
在使用 JMeter 进行性能测试时,难免遇到要求并发请求数比较的场景,此时单台测试机的配置(CPU.内存.带宽等)可能无法支持此性能测试场景.因而,此时 JMeter 提供的分布式测试功能就有了用武 ...
- LeetCode Find All Anagrams in a String
原题链接在这里:https://leetcode.com/problems/find-all-anagrams-in-a-string/ 题目: Given a string s and a non- ...
- Charles常用的十大功能
转载:http://www.jianshu.com/p/2745dbb97cc2 简介 Charles是在 Mac 下常用的网络封包截取工具,在做移动开发时,我们为了调试与服务器端的网络通讯协议,常常 ...
- vim - char code and charset
In normal mode, type ga to display the decimal and hex values for the character under the cursor, or ...
- RDIFramework.NET框架Web中datagrid与treegrid控件自动生成右键菜单与列标题右键菜单
在实际应用中常可以看到数据展示控件有右键菜单的功能,对应的列标题也可以右键弹出快捷菜单设置指定列的显示与隐藏等功能.在我们的RDIFramework.NET Web框架中,只要是使用了EasyUI的D ...
- Hadoop2.x的Eclipse插件编译与安装
Eclipse的Hadoop插件在开发hadoop应用程序中可以提供一些很方便的操作,可以直接Eclipse中浏览HDFS上的文件,可以直接新建选择MapReduce项目,项目自动包含所有需要的had ...
- Unity5 项目设置 .gitignore 解决 Missing Prefab 问题
同步Unity工程时候,两边总是出现Missing Prefab问题. 按照网上的教程设置是无效的. 后来Google了一下 才发现 新版Unity和旧版的设置方式是不同的. 1.在 Edit-&g ...