Git Intro

Introduction

What’s a “git“?

CyanogenMod uses a special program for storing, distributing, maintaining, and synchronizing the thousands of source code files that make up Android. The system, known as a version control system, is called git.

git was developed primarily by Linus Torvalds and is used not only by CyanogenMod, but by AOSP (Android Open Source Project– the vanilla Android source code from Google), the Linux Kernel, and countless open source projects around the world.

git allows every developer to have their own full copy (called a “git repository”) of all the source code that is used to build CyanogenMod. The code base can be easily re-synchronized with a single command so that it is always kept up-to-date. Just as important, git allows developers to easily contribute their bug fixes and enhancements back, where it may be accepted to become part of the official repository.

Because git is “decentralized”, a developer can send their changes (known in git terminology as a “commit“) not only back to CyanogenMod, but to any other person’s repository (with their permission, of course). Similarly, they can receive commits from CyanogenMod or from anyone else.

git is extremely powerful. It allows you to track the history of any files or directories over time, create instant “branches” for safely making experimental changes, add or subtract changes made by yourself or others, see where specific lines of code originated, merge your directories with other contributions, and much, much more.

Confused? Great. Keep reading.

What’s “github”?

As git has become extremely popular, several web sites have popped up to make using git super easy. One of the more popular sites, and the one that CyanogenMod uses to host its source code, is called GitHub. Github offers free git repositories for public projects.

Where can I learn how to use git?

There are many, many places online to learn about git. Each is geared to a particular audience. Some people who learn git may have had experience with other version control systems. Due to the power git offers, there are even people using git who aren’t developers; it can be used for any kind of collaborative project where you might need to track files and directories.

If you have used such non-distributed version control systems as cvs or svn, you will be delighted by this video of Linus Torvalds explaining git‘s advantages at the Google campus:

  • Linus Torvalds talks about git at Google – watch this even if you know nothing about versioning systems. You won’t understand everything, but that’s okay. It’s really a must-see if you have the slightest interest in using git

One nice thing about github.com is that they do a terrific job of introducing git-related concepts through some tutorials. So if you’re new to git or github, take a look at this video:

Some more places to learn:

Where are the official CyanogenMod github repositories?

Right here. These directories are the component repositories that come together to form the CyanogenMod source code.

What’s the best way to download all the CyanogenMod source code repositories from github.com to my computer?

Because there are several dozen git repositories that come together to form the full CyanogenMod source code base, there needs to be a way to keep track of all the repositories and make sure they are all in sync. That method is specific to Android, and it is called repo. repo is an Android tool used to manage all the git repositories that form Android and synchronize them (using the repo sync command) to your computer.

Rather than discuss how to use the repo command on this page in any detail, it may be best to refer you to the Build Guides on this wiki, which do walk you through downloading and using repo in the context of building CyanogenMod for your device.

Content of this page is based on informations from wiki.cyanogenmod.org, under CC BY-SA 3.0 licence.