github使用总结

来源:互联网 发布:防广告弹出软件 编辑:程序博客网 时间:2024/05/21 22:29

1、架设git服务器
http://git-scm.com/book/ch4-7.html
2、Github使用总结
如何向github上的项目提交patch?
http://xiaocong.github.io/blog/2013/03/20/team-collaboration-with-github/
步骤:
在github网站上设置git仓库为ssh方式,并将做开发的主机的key加入到sshkey中

git clone git@github.com:hjwsm1989/ceph.gitgit checkout –b next origin/next

修改文件

git commit –agit push origin next

然后点击提交pull request请求,参与讨论

更新github项目

git remote add rceph git@github.com:ceph/ceph.gitgit fetch rcephgit merge rceph/next(若当前为next分支)git push origin next

若要更新master分支:

git checkout mastergit merge rceph/master

若源项目所有者不赞成你的pull request,而将其关闭了,你该如何同步代码?
如果是已经被merge后关闭的Pull Request,你可以在页面的最下方找到一个“Delete this branch”的蓝色按钮。
或在本地删除远程分支

git push origin :osd-bench

若出现如下! [remote rejected] osd-bench (deletion of the current branch prohibited)
需要在github中确认,这表明这个主题branch的历史使命已经完成(fix-unicode-error的commit已经被合并到主项目中),可以安全地从远程库中删除了。
在本地库中亦可删除这个bran$ git branch -d fix-unicode-error(一定要从本地删除该分支)如果你的主题branch并没有被merge就被维护者关掉的话,你有如下几种选择:
1、你还可以继续再拿它来开新的Pull Request
Signed-off: Random J Developer <random@developer.example.org>
删除github上的这个branch,然后从本地的git上push;
直接git push出错:

[huangjun@CodeMake ceph]$ git pushTo git@github.com:hjwsm1989/ceph.git ! [rejected]        master -> master (non-fast-forward)error: failed to push some refs to 'git@github.com:hjwsm1989/ceph.git'To prevent you from losing history, non-fast-forward updates were rejectedMerge the remote changes before pushing again.  See the 'Note aboutfast-forwards' section of 'git push --help' for details.

方法:
A、 在github上删除这个分支
查看分支:https://github.com/hjwsm1989/ceph/branches
B、 把本地的分支push到远程

git push origin HEAD:master

本地开发过程:

0)  git submodule update –init(初始化一些本地的模块s3等)1)  git pull rceph2)  git merge rceph/master3)  安装一些库,本地开发环境搭建等4)  git archive –o ceph-XX.zip HEAD5)  mkdir ~/rpmbuild/SOURCES/ceph-xx  && mv ceph-XX.zip ~/rpmbuild/SOURCES/ceph-xx6)  unzip ~/rpmbuid/SOURCES/ceph-xx/ceph-xx.zip7)  cp –r xx/src/libs3 ~/rpmbuid/SOURCES/ceph-xx/src/8)  tar –cvzf ceph-xx.tar.gz ceph-xx9)  rpmbuild –bb ~/rpmbuild/SPECS/ceph.spec
0 0