osg(osg中文社区)-osgEarth-osgViewer-基于OpenGL-开源三维渲染引擎-图形引擎-虚拟仿真工具-osg教程-osg仿真

GIT

当前位置:首页 > 下载中心 > 代码托管

原文:http://www.openscenegraph.org/index.php/download-section/code-repositories/31-git-mirror

我没用过GIT,翻译的有点乱。当前使用git来贡献OSG代码的方式并不通,但可以使用GIT签出代码。 ---FreeSouth。

在2010年3月,OSG开始在GIT上启动布置镜像的计划。下面列出了使用GIT获取OSG源码的方法。


软件

  • Windows:

  • Mac:

  • Linux:

    • 使用命令行的,可以安装git: sudo apt-get install git-core

    • 使用可视化的,可以安装gitk: sudo apt-get install gitk

    • 可视化的还可以使用git-gui:sudo apt-get install git-gui

位置

OSG镜像位于github 和 gitorious 上。


迁出只读

使用如下命令

~ $ git checkout git://github.com/openscenegraph/osg.git

万一被防火墙什么的拦截,还可以使用如下命令

~ $ git checkout http://github.com/openscenegraph/osg.git

签出后进行更新使用如下命令

~/OpenSceneGraph $ git pull


贡献代码

如果打算贡献代码到OSG,首先需要将你的修改记录保存起来,然后提交到GitHub的自建分支,这样维护人员才能将其合入到GitHub的主干当中。

首先需要一个 GitHub 帐号。

1. 建立OSGGit自建分支

使用刚才的帐号,登录git,然后到OSG的项目主页 http://github.com/openscenegraph/osg

 点击Fork按钮来创建分支。当分支创建完成,你就获取到了一个OSG项目的拷贝如下:

 

90e23244023e23f992cb4af7f3856108_osg-contributor-repositories.png

2. 签出自建分支到本地

回到自己的PC机,把自建分云签出到本地,要确保签出的是你刚才自己Fork的分支,而不是OSG的主分支。这样你才可以将你修改的代码有权限提交到你的自建分支当中。

~ $ git clone git@github.com:[your-github-account]/osg.git

一旦签出完成,你就在分支上有了一个名为"origin"的远程原始库。

~/osg (master)$ git remote -v origin git@github.com:[your-github-account]/osg.git (fetch) origin git@github.com:[your-github-account]/osg.git (push)

3. 建立UPSTREAM分支

upstreamrepository that you forked

为了根踪你所做的修改,需要在你的分支上建立upstream分支。

~/osg (master)$ git remote add upstream git://github.com/openscenegraph/osg.git

当前你就有了另一个远程库(origin与upstream):

~/osg (master)$ git remote -v origin git@github.com:[your-github-account]/osg.git (fetch) origin git@github.com:[your-github-account]/osg.git (push) upstream git://github.com/openscenegraph/osg.git (fetch) upstream git://github.com/openscenegraph/osg.git (push)

4.创建一个新分支包含你贡献的代码

创建一个名为"topic"的新分支:

~/osg (master)$ (master)> git checkout -b topic Switched to a new branch 'topic' ~/osg (topic)$ git branch master * topic

此时修改代码并提交到topic分支。

5.保持你的分支始终是最新的

创建分支是贡献OSG代码最为推荐的方式,但是它不会自动的去主分支更新,使各分支同步。在topic之前建立的upstream库可以帮你把最新代码合入到主干当中。

~/osg (master)$ git pull upstream master

现在你的upstream/master分支都包含了你的提交,你可以进行合并。

~/osg (master)$ git merge upstream/master

6.保持你的贡献是最新的

需要对master分支更新,重取基线。

~/osg (topic)$ git rebase master

7.提交你的贡献

这项工作目前还没有完成。坑爹呀,白弄这么半天。


Mirorring process

The mirroring process was fairly simple :

  1. use svn2git(my mirror added a --continue flag if the execution failed the svn fetch process) :

    ~ $ svn2git http://www.openscenegraph.org/svn/osg/OpenSceneGraph

  2. add remotes to push changes to

    ~/OpenSceneGraph (master)$ git remote add github git@github.com:openscenegraph/osg.git ~/OpenSceneGraph (master)$ git remote add gitoriousgit@gitorious.org:openscenegraph/osg.git

  3. create a shell script osg-svn2git.shto update and push changes

    #!/bin/sh cd ~/OpenSceneGraph /usr/bin/git svn fetch /usr/bin/git merge trunk /usr/bin/git push --mirror gitorious /usr/bin/git push --mirror github

  4. add the shell script to the crontab

    */5 * * * * ~/osg-svn2git.sh