Creating your own fork of OpenCog

From OpenCog
Jump to: navigation, search

Description

This page describes how to make your own fork of OpenCog so you have your own version of the OpenCog codebase to work with.

A fork is basically a copy of an existing repository that retains a connection to the origin. This connection makes it possible for git to integrate changes that you make to your fork to the original repository, as well as giving viewers of the original repository the ability to see which forks have been made and what is happening on them.

When you clone your own fork to your local system, another such connection is logged, so that any changes you make locally can be integrated into your own fork. Once you have pushed these changes to your own fork, you can use the GitHub website to make submit a pull request so that one of the administrators of the main OpenCog repository can evaluate your changes and if desirable, approve them for integration into the main OpenCog repository.

Prerequisites

This page has the following prerequisites:

  • A GitHub account (create one here)

Contents

Forking the OpenCog repository

After signing up for GitHub (see prerequisites above) you will land on the main GitHub page as shown below.

width:800px


Go to the main OpenCog repository at

http://www.github.com/opencog/opencog

You should see the main page of the OpenCog repository as shown below.

GitHub OpenCog start page.png



In the top right part of the page, you should see the 'Fork' button. Click on it.

While GitHub is busy making your fork, you should see the page below.

GitHub OpenCog forking.png



Once it's complete, you should have been redirected to your own OpenCog repository under your own GitHub user account, as shown below.

GitHub OpenCog fork complete.png


Now you have your own brand new fully up-to-date fork, you should make sure your local repository (~/src/ochack) is brought up to date with it, and if you wish your local 'backup' repository (/usr/local/src/opencog) as well.

Updating your local repository

Since you're only just beginning to use your own fork, it's very likely that your local repository comes from a clone of /usr/local/src/opencog or directly from the main OpenCog repository at http://github.com/opencog/opencog. Verify this wrong situation by going to your local folder

cd ~/opencog/

and typing

git remote -v

If the output shows

origin	/usr/local/src/opencog (fetch)
origin	/usr/local/src/opencog (push)

or

origin	https://github.com/opencog/opencog.git (fetch)
origin	https://github.com/opencog/opencog.git (push)

Then you need to retarget your local repository to your own fork by typing the command below (replace Alex-van-der-Peet with your own GitHub username of course)

git config remote.origin.url http://github.com/Alex-van-der-Peet/opencog

verify all went well with another

git remote -v

Which should then show something like

origin	http://github.com/Alex-van-der-Peet/opencog (fetch)
origin	http://github.com/Alex-van-der-Peet/opencog (push)

Make sure everything is up to date by typing out a pull:

git pull origin master

Note: It is common at this time to create a separate branch, as well, to make reviewing your code easier on anyone conducting a pull from your repository, and to conduct all fresh work on this new branch. However, this is beyond the scope of this article; we recommend reading up on git for more information. Pushes and pulls are then conducted entirely on the new branch of the new fork with:

git push origin new_branch_name
git pull origin new_branch_name

Normally it is good practice to also create a second remote leading to the original repository at opencog/opencog (the 'upstream' repository) so that you yourself can pull new changes made to the core code. Do that using this command:

git remote add upstream http://github.com/opencog/opencog

Now when you ask git to tell you how it is configured:

git remote -v

It should tell you something like this:

origin	https://github.com/Alex-van-der-Peet/opencog.git (fetch)
origin	https://github.com/Alex-van-der-Peet/opencog.git (push)
upstream	http://github.com/opencog/opencog (fetch)
upstream	http://github.com/opencog/opencog (push)

To push and pull your own local code, you then con tinue to use:

git push origin new_branch_name
git pull origin new_branch_name

But when you wish to pull new changes to the original repository, you pull them into your own master branch using the command:

git pull upstream master

And then (assuming your working branch, new_branch_name, is still checked out) merge changes into that working branch using:

git push origin master
git merge origin master
git push origin new_branch_name

References