Git: Difference between revisions

From OLPC
Jump to navigation Jump to search
(→‎Git Commands: word smithing)
 
(9 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{draft}}
{{linux software}}
{{linux software}}
{{rightTOC}}
{{rightTOC}}


== Description ==
== About Git ==


'''Git''' is a version control system (sometimes called a "revision control system") for programmers used to track and manage changes to code. It is a decentralized system, with no "master" tree, and was originally written by Linus Torvalds to manage the Linux kernel sources. Git is used by many open source projects to manage development among programmers, and is used by the OLPC as its preferred version control system.
'''Git''' is a revision control system (sometimes called a "version control system") for programmers used to track and manage changes to code and other data. Git is a decentralized system, with no "master" tree, and was originally written by Linus Torvalds to manage the Linux kernel sources. Git is used by many open source projects to manage development among programmers, and is used by the OLPC as its preferred version control system.


=== A short overview of a version control system ===
== Installation ==
The version control system provides the detailed information on the source code. Using the repository, a user can:
* Browse or download the current source code and data files .
* Browse or download any version that was ever put in the repository.
* See the comments explaining why changes were made.
* See what changed betweens versions.
* See which versions were picked for which releases, also known as 'heads'.


Users that have write access (or ''commit access'') to the repository can do more:
First, you'll need to fetch and install [[Git]] on your machine. The tarball with the latest version is always available at the [http://git.or.cz git site], and you might find your distribution provides packages. You can expect that the OLPC servers will always be running close to the latest version of the git tools.
* Add new files to a project.
* Add changes back into the repository, creating new versions.
* Edit comments to explain why changes were made.
* Merge changes made from two different people into a single version.
* Create a separate branch of development to keep changes separate from others.


For more information about version control systems, see [http://en.wikipedia.org/wiki/Revision_control Wikipedia]
:In OpenSuSE

=== Installation ===

You will generally install Git on whatever machines you are currently using for development and testing.

First, you'll need to fetch and install [[Git]] on your machine. The tarball with the latest version is always available at the [http://git-scm.com/ git site], and you should find your distribution provides packages.

*using Red Hat, Fedora, including OLPC OS on an XO laptop, install the ''git'' package:

sudo yum install --yes git

*using Debian, Ubuntu, and related distributions, the package name was already taken, so you must choose ''git-core'':

sudo apt-get install --yes git-core

*using OpenSuSE, install the ''git'' package:


yast --install git
yast --install git


== Using Git for the OLPC Project ==
: In RedHat & XO Laptop


=== The OLPC Git Repository ===
sudo yum install git


Many projects maintain their source code in a git repository at http://dev.laptop.org/git. The allows anyone to browse and download source code for the Sugar operating system, the Sugar shell, activities typically installed on the XO, and activities under development. Browsing through the source code is a great way of introducing yourself to programming in general, and for programming the XO. While most projects are written in Python, some are written in other languages such as Squeak or C.
:In Ubuntu 7/Feisty and Debian Etch (and presumably earlier) "git" still refers to gitfm, an unrelated tool. To fix in feisty:


As an example, let's look at the [[Memorize]] activity back in 2006. This activity was bundled with the G1G1 laptops and is reasonably complete and mature. That is, it has few bugs, most of its features, and has most of its documentation. The Git repository is only one piece of the activity's information on the OLPC websites. Here is the Memorize activity's information:
sudo apt-get install git-core cogito
* [[The_OLPC_Wiki#About_this_wiki|Wiki]]: [[Memorize|This page]] with links, rules, and a development roadmap.
sudo update-alternatives --config git
* [[Trac]]: [https://dev.laptop.org/query?component=memorize&status=new&status=reopened&order=priority This page] tracking bugs and enhancement requests.
* [[Test_issues|Tests]]: [[Tests/Memorize|This page]] describing a test plan for the activity.
* [[Activities|Activities Summary]]: [[Activities|This page]] describing all running activities with links to downloadable .xo files. You will need to scroll down to find Memorize.
* [http://dev.laptop.org/git Git Repository]: [http://dev.laptop.org/git?p=projects/memorygame This page] showing the history and organization of source and data files for the activity.


Since then, the Memorize activity has moved to Sugar Labs.
== Running ==


Project names are not the same as activity names. For example, the Git project name is memorygame while the activity name is Memorize.


=== Git Commands ===
=== Browsing Source Online ===


To browse source online, start by going to the main repository page at http://dev.laptop.org/git.
To get a project's code for the first time, use "git clone" :
git-clone git://dev.laptop.org/<project-directory> (To get the code)


Find a project on the list. Each project has four links:
For instance:
* [http://dev.laptop.org/git?p=projects/memorygame;a=summary Summary]: See a short description of the project, the owner, recent changes, and the heads.
git-clone git://dev.laptop.org/activities/epals
* [http://dev.laptop.org/git?p=projects/memorygame;a=shortlog Short log]: One line descriptions of changes.
* [http://dev.laptop.org/git?p=projects/memorygame;a=log Log]: Longer descriptions of the changes. Most developers only enter one line per 'commit'.
* [http://dev.laptop.org/git?p=projects/memorygame;a=tree Tree]: The directory tree of the most recent version.

Click on 'tree'. You can browse into subdirectories by clicking on the links. Download individual source code files by clicking on ''raw'', and view the source code in your browser by clicking on ''blob''.

=== Downloading Source Code ===

Anyone can get a project's code. Use the "git clone" :
git-clone git://dev.laptop.org/<project-directory>

You can enter it as "git clone" or "git-clone". For instance:
git-clone git://dev.laptop.org/projects/memorygame
OR
OR
git clone git://dev.laptop.org/activities/epals
git clone git://dev.laptop.org/projects/memorygame


Note that projects are in random directories of the Git repository, such as 'activities',
Note that projects are in random directories of the Git repository, including 'activities',
'projects', the root directory, and individual user accounts. Check the repository at
'projects', the root directory, and individual user accounts. Check the repository at
http://dev.laptop.org/git for the correct spelling and capitalization of each project.
http://dev.laptop.org/git for the correct spelling and capitalization of each project.


For example, the PlayGo activity is listed as "projects/PlayGo". To clone (or download
For example, the EPals activity is listed as "activites/epals". To clone (or download
a copy of the source code) for the PlayGo activity, use:
a copy of the source code) for the EPals activity, use:
git-clone git://dev.laptop.org/projects/PlayGo
git-clone git://dev.laptop.org/activities/epals


While the 'sugar' project is in the root directory:
While the 'sugar' project is in the root directory:
git-clone git://dev.laptop.org/sugar
git-clone git://dev.laptop.org/sugar
You can update the code as follows:
git-pull (To update the code)
git-status -a (To see the status of your commits)
git-checkout -- (To undo your commits)
git checkout HEAD -- filename (To replace filename with the one at HEAD)


When you cannot find a project in the repository, remember that the project name and the activity name are not always related. Search for the project in the wiki. Even projects that do not host their code in the OLPC Git Repository will provide information on their wiki page.
== Git for OLPC ==

To get a project of yours hosted in our Git instance, '''see [[Project hosting]]'''.
== Git for Developers of New Projects ==

You can get a project of yours hosted in our Git instance, '''see [[Project hosting]]'''. In general, you apply after you have some amount of running code hosted on another site or source code control system. You will need to provide a public key in your application.

=== Some sites of interest at dev.laptop.org ===


OLPC GIT: http://dev.laptop.org/ (for tracking and submitting bugs and tasks)
OLPC GIT: http://dev.laptop.org/ (for tracking and submitting bugs and tasks)
Line 64: Line 106:
Tickets: http://dev.laptop.org/query
Tickets: http://dev.laptop.org/query


=== Git Commands for updating code ===
== Further Resources ==
You can update the code as follows:
git-pull (To update the code)
git-status -a (To see the status of your commits)
git-checkout -- (To undo your commits)
git checkout HEAD -- filename (To replace filename with the one at HEAD)

== See also ==


{{:Git/See_also}}
* [http://git.or.cz/ git] home page
* [http://git.or.cz/#download Download git-core] or
* Read more about git [http://en.wikipedia.org/wiki/Git_(software) on Wikipedia]
* [http://freedesktop.org/wiki/UsingGit Freedesktop Git]
* [[Using a central git tree]]
* [[Importing your project]]
* [[Creating a personal git tree]]


[[Category:Git]]
[[Category:Git]]
[[Category:Developers]]
[[Category:Developers]]
[[Category:Software projects]]
[[Category:Software development]]
[[Category:Software development]]
[[Category:Sugar]]

Latest revision as of 05:10, 2 July 2014

This command is run in the standard Linux environment via the Terminal Activity. The GUI will probably not integrate comfortably with the XO Laptop's Sugar environment. Your user experience may vary considerably depending on the established environment and the other programs running on the laptop, may need re-installation after an OS Update. See the Linux software category for other commands.


About Git

Git is a revision control system (sometimes called a "version control system") for programmers used to track and manage changes to code and other data. Git is a decentralized system, with no "master" tree, and was originally written by Linus Torvalds to manage the Linux kernel sources. Git is used by many open source projects to manage development among programmers, and is used by the OLPC as its preferred version control system.

A short overview of a version control system

The version control system provides the detailed information on the source code. Using the repository, a user can:

  • Browse or download the current source code and data files .
  • Browse or download any version that was ever put in the repository.
  • See the comments explaining why changes were made.
  • See what changed betweens versions.
  • See which versions were picked for which releases, also known as 'heads'.

Users that have write access (or commit access) to the repository can do more:

  • Add new files to a project.
  • Add changes back into the repository, creating new versions.
  • Edit comments to explain why changes were made.
  • Merge changes made from two different people into a single version.
  • Create a separate branch of development to keep changes separate from others.

For more information about version control systems, see Wikipedia

Installation

You will generally install Git on whatever machines you are currently using for development and testing.

First, you'll need to fetch and install Git on your machine. The tarball with the latest version is always available at the git site, and you should find your distribution provides packages.

  • using Red Hat, Fedora, including OLPC OS on an XO laptop, install the git package:
sudo yum install --yes git
  • using Debian, Ubuntu, and related distributions, the package name was already taken, so you must choose git-core:
sudo apt-get install --yes git-core
  • using OpenSuSE, install the git package:
yast --install git

Using Git for the OLPC Project

The OLPC Git Repository

Many projects maintain their source code in a git repository at http://dev.laptop.org/git. The allows anyone to browse and download source code for the Sugar operating system, the Sugar shell, activities typically installed on the XO, and activities under development. Browsing through the source code is a great way of introducing yourself to programming in general, and for programming the XO. While most projects are written in Python, some are written in other languages such as Squeak or C.

As an example, let's look at the Memorize activity back in 2006. This activity was bundled with the G1G1 laptops and is reasonably complete and mature. That is, it has few bugs, most of its features, and has most of its documentation. The Git repository is only one piece of the activity's information on the OLPC websites. Here is the Memorize activity's information:

Since then, the Memorize activity has moved to Sugar Labs.

Project names are not the same as activity names. For example, the Git project name is memorygame while the activity name is Memorize.

Browsing Source Online

To browse source online, start by going to the main repository page at http://dev.laptop.org/git.

Find a project on the list. Each project has four links:

  • Summary: See a short description of the project, the owner, recent changes, and the heads.
  • Short log: One line descriptions of changes.
  • Log: Longer descriptions of the changes. Most developers only enter one line per 'commit'.
  • Tree: The directory tree of the most recent version.

Click on 'tree'. You can browse into subdirectories by clicking on the links. Download individual source code files by clicking on raw, and view the source code in your browser by clicking on blob.

Downloading Source Code

Anyone can get a project's code. Use the "git clone" :

git-clone git://dev.laptop.org/<project-directory> 

You can enter it as "git clone" or "git-clone". For instance:

git-clone git://dev.laptop.org/projects/memorygame
    OR 
git clone git://dev.laptop.org/projects/memorygame

Note that projects are in random directories of the Git repository, including 'activities', 'projects', the root directory, and individual user accounts. Check the repository at http://dev.laptop.org/git for the correct spelling and capitalization of each project.

For example, the EPals activity is listed as "activites/epals". To clone (or download a copy of the source code) for the EPals activity, use:

git-clone git://dev.laptop.org/activities/epals

While the 'sugar' project is in the root directory:

git-clone git://dev.laptop.org/sugar

When you cannot find a project in the repository, remember that the project name and the activity name are not always related. Search for the project in the wiki. Even projects that do not host their code in the OLPC Git Repository will provide information on their wiki page.

Git for Developers of New Projects

You can get a project of yours hosted in our Git instance, see Project hosting. In general, you apply after you have some amount of running code hosted on another site or source code control system. You will need to provide a public key in your application.

Some sites of interest at dev.laptop.org

OLPC GIT: http://dev.laptop.org/  (for tracking and submitting bugs and tasks)

    Wiki: http://dev.laptop.org/wiki
 Roadmap: http://dev.laptop.org/roadmap
 Sources: http://dev.laptop.org/browser
 Tickets: http://dev.laptop.org/query

Git Commands for updating code

You can update the code as follows:

git-pull (To update the code)
git-status -a  (To see the status of your commits)
git-checkout -- (To undo your commits)
git checkout HEAD -- filename (To replace filename with the one at HEAD)

See also