FroboMind:How to use Git and GitHub

From FroboMind [www.frobomind.org]
Jump to: navigation, search

Introduction

This guide explains how to use Git and GitHub together with FroboMind. The guide will not explain in detail how Git and GitHub works, however it will provide you with the basic commands needed to use the GitHub repository in your projects.

The guide assumes that you have followed the instructions given in the FroboMind Installation Guide exactly. If you made any changes to the instructions procedure such as installing FroboMind in another directory you will need to adapt this guide as well.

The guide use the same terminology as the FroboMind Installation Guide:

  • FroboLab/FroboMind.git repository is the original FroboMind repository.
  • YourUserName/FroboMind.git is your personal repository which you created when following the FroboMind Installation Guide. This repository is a fork of the FroboLab/FroboMind.git repository.
  • Your local repository is the repository stored locally on your computer. This repository is a clone of the YourUserName/FroboMind.git repository. If you use more computers you will have a local repository on each of them.


Generic tools

The guide will describe common Git task which you will need to use on a regular basis. To keep track of which updates have been committed to your local repository, to your YourUserName/FroboMind.git repository and to the FroboLab/FroboMind.git we recommend that you become familiar with the gitk application. Run these commands to see all commits:

cd ~/roswork/src
gitk --all


Guide to common Git tasks

Initial fork and clone of the FroboLab/FroboMind.git repository

The steps for forking and cloning the FroboMind repository are described in the FroboMind Installation Guide.


Updating your local cloned repository from your forked FroboLab/FroboMind.git repository

These steps show how to update your local repository with any previous commits to your forked FroboLab/FroboMind.git repository (which will be named YourUserName/FroboMind.git). The commits may be from yourself on another computer or from other developers within your team.

Run these commands:

cd ~/roswork/src
git fetch

If the last command shows any output run this command:

git rebase origin/master


Adding updates from your local cloned repository to your forked FroboLab/FroboMind.git repository

Whenever you make changes in you local cloned repository you need to commit these to your forked FroboLab repository (which will be named YourUserName/FroboMind.git).

It is recommended to use the graphical application git-gui to commit the individual changes:

git gui

Then to push the commits to your forked repository run these commands:

cd ~/roswork/src
git push

If you receive an error while trying to run the git push command it is possibly because someone else (maybe you from another computer) pushed other commits before you. In that case you need to update your local cloned repository as described in the section above and then retry the commands described here.


Updating your local cloned repository from the FroboLab/FroboMind.git repository

When following the FroboMind Installation Guide you created a fork of the FroboLab/FroboMind.git repository to your YourUserName/FroboMind.git repository. After this point your YourUserName/FroboMind.git will not automatically receive any updates made to the FroboLab/FroboMind.git repository.

To update your local repository with new commits from the FroboLab/FroboMind.git repository run these commands:


First time configuration

Run this command:

git remote add upstream http://github.com/FroboLab/FroboMind.git
Each time you want to update

Run these commands:

cd ~/roswork/src
git fetch upstream

If the last command shows any output run this command:

git merge upstream/master


Please notice that these commands will update only your local repository, your YourUserName/FroboMind.git repository is currently left unchanged. In order to update your YourUserName/FroboMind.git repository as well you now need to run the commands described in the section above.


References

  • You can download the latest version of Git from the official Git website git-scm.com.
  • The official Git documentation is available at git-scm.com/documentation.
  • Be introduced to the basic concepts of Git version control at Codeschool.