ubuntu使用github
Ubuntu下安装Git
Ubuntu12.04 LTS默认是已经安装Git的,可以使用 git --version 测试是否安装。
如果没有安装,使用命令: sudo apt-get install git git-core 安装git
ssh认证
官网教程: https://help.github.com/articles/generating-ssh-keys/
创建公钥 ssh key
carloz@linux:~/Downloads/usr/bin$ ls -al ~/.ssh
total 16
drwx------ 2 carloz carloz 4096 10月 29 17:06 .
drwxr-xr-x 42 carloz carloz 4096 10月 29 16:39 ..
-rw------- 1 carloz carloz 1679 10月 29 16:44 github
-rw-r--r-- 1 carloz carloz 403 10月 29 16:44 github.pub
carloz@linux:~/Downloads/usr/bin$ ssh-keygen -t rsa -b 4096 -C "xiaoqing_work@163.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/carloz/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): xiaoqing
Enter same passphrase again:
Your identification has been saved in /home/carloz/.ssh/id_rsa.
Your public key has been saved in /home/carloz/.ssh/id_rsa.pub.
The key fingerprint is:
66:b5:f4:85:37:4c:c1:7e:bf:d3:bd:c1:7a:d7:2d:f5 xiaoqing_work@163.com
The key's randomart image is:
+--[ RSA 4096]----+
| .o. |
| +. |
| o ..= |
| o o o...|
| S . . ..|
| o . o|
| +B|
| o+E|
| ..o+|
+-----------------+
carloz@linux:~/Downloads/usr/bin$
复制公钥
carloz@linux:~/Downloads/usr/bin$ ls -al ~/.ssh
total 24
drwx------ 2 carloz carloz 4096 10月 29 17:12 .
drwxr-xr-x 42 carloz carloz 4096 10月 29 16:39 ..
-rw------- 1 carloz carloz 1679 10月 29 16:44 github
-rw-r--r-- 1 carloz carloz 403 10月 29 16:44 github.pub
-rw------- 1 carloz carloz 3326 10月 29 17:12 id_rsa
-rw-r--r-- 1 carloz carloz 747 10月 29 17:12 id_rsa.pub
carloz@linux:~/Downloads/usr/bin$ vi ~/.ssh/id_rsa.pub
carloz@linux:~/Downloads/usr/bin$ eval "$(ssh-agent -s)"
Agent pid 8644
carloz@linux:~/Downloads/usr/bin$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /home/carloz/.ssh/id_rsa: xiaoqing
Identity added: /home/carloz/.ssh/id_rsa (/home/carloz/.ssh/id_rsa) carloz@linux:~/Downloads/usr/bin$ sudo apt-get install xclip
carloz@linux:~/Downloads/usr/bin$ xclip -sel clip < ~/.ssh/id_rsa.pub
添加key到github


连接 github
carloz@linux:~/Downloads/usr/bin$ rm ~/.ssh/git*
carloz@linux:~/Downloads/usr/bin$ ls -al ~/.ssh
total 16
drwx------ 2 carloz carloz 4096 10月 29 17:23 .
drwxr-xr-x 42 carloz carloz 4096 10月 29 16:39 ..
-rw------- 1 carloz carloz 3326 10月 29 17:12 id_rsa
-rw-r--r-- 1 carloz carloz 747 10月 29 17:12 id_rsa.pub
carloz@linux:~/Downloads/usr/bin$ 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 carlo-z! You've successfully authenticated, but GitHub does not provide shell access.
carloz@linux:~/Downloads/usr/bin$
提交代码至GitHub
cd carloz-lib-web/
carloz@linux:~/Python/carloz/carloz-lib-web$ git config --global user.name "carlo-z" carloz@linux:~/Python/carloz/carloz-lib-web$ git config --global user.email xiaoqing_work@163.com git init
git add .
git commit -m "add new files"
git remote add origin git@github.com:carlo-z/carloz-lib-web.git
git push -u origin master
carloz@linux:~/Python/carloz/carloz-lib-web$ git push origin master
To git@github.com:carlo-z/carloz-lib-web.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:carlo-z/carloz-lib-web.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
carloz@linux:~/Python/carloz/carloz-lib-web$ git fetch
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:carlo-z/carloz-lib-web
* [new branch] master -> origin/master
carloz@linux:~/Python/carloz/carloz-lib-web$
! [rejected] master -> master (non-fast-forward)
问题(Non-fast-forward)的出现原因在于:git仓库中已经有一部分代码,所以它不允许你直接把你的代码覆盖上去。于是你有2个选择方式:
1,强推,即利用强覆盖方式用你本地的代码替代git仓库内的内容
git push -f
carloz@linux:~/Python/carloz/carloz-lib-web$ git push -f origin master
Counting objects: 663, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (636/636), done.
Writing objects: 100% (662/662), 3.00 MiB | 23.00 KiB/s, done.
Total 662 (delta 13), reused 0 (delta 0)
To git@github.com:carlo-z/carloz-lib-web.git
+ 04e543c...e29d7a9 master -> master (forced update)
2,先把git的东西fetch到你本地然后merge后再push
ubuntu使用github的更多相关文章
- [转]Ubuntu下GitHub的使用
转自Pythoner 本文将对Ubuntu下Git的安装,以及如何连接GitHub进行讲解. 1.环境 OS: Ubuntu13.04 64bitsGit: 1.8.1.2 2.Git安装 执行如下命 ...
- Ubuntu+Hexo+Github搭建个人博客
Ubuntu+Hexo+Github搭建个人博客 目录 目录 目录 1. 简介 环境 2. Git安装及配置 2.1 安装Git 2.2 创建Git仓库 2.3 配置git仓库 2.4 添加公钥 3. ...
- ubuntu 下 github 使用方法 以及异常修改
接触github很长时间了,github有windows 跟 mac 版本,恶心的是现在在linux 下没有可视化界面的版本.所以对于很多没有怎么接触过github的人带来很大困难.话不多说,彪重点: ...
- ubuntu 设置github秘钥
github的SSH配置如下: 一 . 设置Git的user name和email: $ git config --global user.name "AmyOrz" $ git ...
- Ubuntu下github pages+hexo搭建自己的博客
hexo 是一个基于Node.js的静态博客程序,可以方便的生成静态网页托管在github上.Hexo简单优雅, 而且风格多变, 适合搭建个人博客,而且支持多平台的搭建. 平台 Ubuntu14.04 ...
- ubuntu在github上传项目
GitHub是一个面向开源及私有软件项目的托管平台,因为只支持git 作为唯一的版本库格式进行托管,故名GitHub. 作为开源代码库以及版本控制系统,Github拥有超过900万开发者用户.随着越来 ...
- git常用指令
<a>github的提交方式 git status (1)git add .--------------------存储到本地 git add -u ...
- docker learning
Docker 配置文件位置 Docker 的配置文件可以设置大部分的后台进程参数,在各个操作系统中的存放位置不一致 在 ubuntu 中的位置是:/etc/default/docker 在 cento ...
- 需要熟记的git命令
需要熟记的github常用命令 总结一下ubuntu下github常用的命令,设置部分跳过,假设repository的名字叫hello-world: .创建一个新的repository: 先在gith ...
随机推荐
- MySQL 优化Limit分页
很多时候.我们需要选择出从指定位置开始的指定行数.此时.limit笑了 对于limit的定义是: limit x,y 表示从第x行开始选择y条记录 在业务需要 ...
- Android开发之50个常见实用技巧——添加悦目的动画效果
Hack.5 使用TextSwitcher和ImageSwitcher实现平滑过渡 实现步骤: 1.通过findViewById()方法获取TextSwitcher对象的引用Swithcer,当然也可 ...
- SAP HANA STRING_AGG
HANA Version 1.00.73.00.389160 不支持STRING_AGG,所以只能,,,,,,,, DROP PROCEDURE ""."ZCONCAT_ ...
- Android开发之点九图的制作说明
总结: 左边的点代表垂直拉伸的区域, 上边的点代表水平拉伸的区域. 右边的点代表文字等的垂直可可显示区域. 下边的点代表文字等的水平可显示区域. 左上重合的区域就是拉伸区域. 右下重合的区域就是显示区 ...
- git 命令归纳
git 新手一枚,随用随更新 git clone git@example.com:project-name.git 克隆 git branch [-a -r] 查看分支[所有 远端] git pull ...
- 64位开源处理器Rocket该人士介绍
最近大概读一点UCB发布时间Rocket处理器的源代码,的每个文件的源代码的功能有一定的一般理解,Mark一点点. Rocket是一家64bit标量处理器,5第一阶段管道,用途risc-v指令集.综合 ...
- cocos2d-x plist+wen使用
http://zhan.renren.com/tag?value=cocos2dx&from=template http://blog.csdn.net/zhanglongit/article ...
- Graphql graffiti
https://github.com/RisingStack/graffiti-mongoose https://blog.risingstack.com/graffiti-mongoose-mong ...
- Ⅰ.AngularJS的点点滴滴--引导
AngularJS已经被很多人像炒冷饭一样炒过啦,大部分都是直接复制官方文档没有说明一些注意事项,不过什么都要从头开始吧 页面引导实例化 1.自动实例化 <html> <script ...
- CentOS 6.7安装配置Cacti监控系统
一.安装配置LAMP环境 yum -y install httpd php php-mysql php-snmp php-xml php-gd mysql mysql-server 启动http和my ...