Kuku/Git Usage

From OLPC
< Kuku
Revision as of 23:24, 19 November 2007 by 209.7.12.34 (talk)
Jump to navigation Jump to search

trgetco This page describes how the kuku project uses git to manage the source code. Here you will find useful git commands for playing with the kuku code, as well as a description of what each branch means in terms of kuku development. The git commands listed below are in explit (long) form so as to better keep in mind the way git does things.

The thing to keep in mind is that git is all about branching and merging. These operations are at the core of most git commands, so it is good to be comfortable with branching followed by merging for all of the git workflows.

Kuku Branch Structure

The most up to date list of branches can be seen on our trac page. The branches are:

  • master - current development (Trial-3)
  • Trial-2 - Trial-2 development

It is important to note that sugar-jhbuild pulls from the master branch by default.

Git commands for working with Kuku

Importing the Code

git clone git://dev.laptop.org/projects/kuku

Adding a Remote Branch

First create a local branch from the current master branch

git branch trial-2

Push this branch to the remote master

git push origin trail-2:trial-2

Working with Remote Branches

See the remote branches with

git branch -r

Or see local branches with

git branch

Or see all branches with

git branch -a

For each remote branch you want to work on, create a local branch

git branch <local name> <remote name>
git branch my-trial-2 origin/trial-2

Checkout your new branch

git checkout trial-2

add/edit/commit, then push your changes upstream with

git push origin my-trial-2:trial-2

Working with Local Branches

This is usefel to test out an idea locally without adding a branch to the remote master repo. Make a local branch with

git branch local_branch_name branch_start_point

Where the branch_start_point is the name of a branch you want to start working on. For example, to start working on the master remote branch, you can do

git branch my-new-idea origin/master

If you have already made commits to your master branch, and want to branch off of there, you could do

git branch my-new-idea master

Or if you want to do a fix of a trial-2 bug, you could do

git branch trial-2-bug-fix origin/trial-2

See that your new branch is there with

git branch

Switch to that branch

git checkout local_branch_name

add/edit/commit. You can merge this branch with the master branch with

git checkout master
git merge local_branch_name

Suppose you fixed the trial-2 bug you were working on in your trial-2-bug-fix branch and you want to push that upstream. Once you have committed, you can do

git push origin trial-2-bug-fix:trial-2

Once you have committed changes to a local branch, you can remove it with

git branch -d local_branch_name

Or if you don't want to commit, but juts wipe it out, use

git branch -D local_branch_name

Fetching Upstream Changes

Suppose another developer has made changes and you want to see them. This can be done in several ways.

git fetch remote_branch_name

will update your remote branches. You can see these branches with

git branch -r

For example, suppose someone else did a trial-2 bug fix, and pushed the changes to origin/trial-2. You are working in trial-2-bug-fix. You should first fetch the newest code

git fetch origin/trial-2

Now, create a local branch from the newest trial-2 code:

git branch newest-trial-2

Now you can merge this code into your own trial-2-bug-fix branch

git merge newest-trial-2

Make sure things merged correctly, then you can delete your temporary local trial-2 branch

git branch -d newest-trial-2

Useful Links

Git Tutorial Part 1

Git for CVS Users

SourceMage Git Guide

Linus Torvalds on Git - Google Talks - You Tube