github应用小记(LINUX)
来源:互联网 发布:万方等数据库 编辑:程序博客网 时间:2024/06/05 18:48
github是一个分布式的项目托管站点,方便项目的管理,最近一些代码放在自己的机器上感觉不安全,架设一个svn又太繁琐,所以选择使用github。
在linux上使用github有以下步骤:
1、申请账号,创建project.git项目
2、在linux上安装git
yum install git
3、生成github使用的秘钥对
ssh-keygen -t rsa -C "your_email@youremail.com"
4、在github站点上添加ssh秘钥
登陆github系统。点击右上角的 Account Settings--->SSH Public keys ---> add another public keys
把你本地生成的密钥复制到里面(key文本框中), 点击 add key 就ok了
5、测试是否成功
ssh -T git@github.com如果提示:Hi xxx You've successfully authenticated, but GitHub does not provide shell access. 说明你连接成功了
6、创建本地工作目录
mkdir project
# cd project
# git init
# touch README
# git add README
# git commit -m 'first commit'
定义远程服务器别名origin
# git remote add origin git@github.com:xxx/project.git
本地和远程合并,本地默认分支为master
# git push origin master
7、 更新文件
# vi README自动commit更改文件
# git commit -a
更新至远程
# git push origin master
8、 创建和合并分支
#git branch 显示当前分支是master#git branch new-feature 创建分支
# git checkout new-feature 切换到新分支
# vi page_cache.inc.php
# git add page_cache.inc.php
Commit 到本地GIT
# git commit -a -m "added initial version of page cache"
合并到远程服务器
# git push origin new-feature
如果new-feature分支成熟了,觉得有必要合并进master
#git checkout master
#git merge new-feature
#git branch
#git push
则master中也合并了new-feature 的代码
9、删除文件
git rm --cached filename
git commit -m "hehe"
git push origin branch
--cached 的指令 都是和staging area或者叫index有关的,就是git add了但还没有commit出去的状态。
git rm --cached filename 把文件从staging area中删了,再commit,push,就把github里面那份也删了。
常见错误
ssh-add 可能会出现以下错误
Could not open a connection to your authentication agent.这是因为ssh-agent没有运行,执行
exec ssh-agent bash
问题就迎刃而解了,相关问题可查阅http://linux.101hacks.com/unix/ssh-add/
其他参见 http://luozhaoyu.iteye.com/blog/1461705
- github应用小记(LINUX)
- linux小记 find 应用1
- Linux小记(一)
- Linux小记(三)
- Pandas应用小记(一)
- GitHub应用(二)
- Git/Github使用方法小记
- Git/Github使用方法小记
- Git/Github使用方法小记
- Git/Github使用方法小记
- Git/Github使用方法小记
- Git/Github使用方法小记
- Git/Github使用方法小记
- Git/Github使用方法小记
- GitHub小记(一)
- github常用小记
- 使用linux 小记(一)
- Linux常用命令小记(1)
- rails启动过程
- UITableView 系列之自定义 UITableViewCell
- 按单词反转字符串
- 黑马程序员---选择排序 冒泡排序
- Codeforces Round #234 (Div. 2)
- github应用小记(LINUX)
- Ubuntu 12.04下解决Rhythmbox Music Player乱码问题
- 转:sudoers文件
- c# 多线程委托带参数传递
- 觉醒-决心
- 缺少commons-lang-2.5包报错
- WebService,SOAP
- Hibernate悲观锁/乐观锁
- JDK包含JRE