Differences between revisions 68 and 69
Revision 68 as of 2010-06-08 07:55:04
Size: 9864
Editor: nikai
Comment: sp
Revision 69 as of 2010-06-21 09:06:40
Size: 8237
Editor: apw
Deletions are marked like this. Additions are marked like this.
Line 31: Line 31:
= Installing GIT = == Installing GIT ==
Line 41: Line 41:
= Getting the Ubuntu Linux kernel repo =
Line 43: Line 42:
The Ubuntu Linux kernel git repository is located at
git://<release>.git or<release>.git. To download a local
copy of the repo, use this command:
Line 47: Line 44:
git clone git://
== Maintaining local changes ==
Line 51: Line 46:
This will take some time depending on your connection. There is several
hundred megabytes of data to download.

Alternately, if you plan on working on more than one kernel release you can save space
and time by downloading the upstream kernel tree. Then, other releases can
be downloaded with the --reference option which will avoid downloading redundant objects:

git clone git://
git clone --reference linux-2.6/ git://
git clone --reference linux-2.6/ git://
git clone --reference linux-2.6/ git://

Change into the directory:

cd ubuntu-jaunty}}}

By default you will have the latest version of the kernel tree, the
master tree. You can get a copy of the kernel version you want to work
on. To determine which the latest official release is:

git tag -l Ubuntu-*}}}

This results in something like this:


For example, with the exact above output you could checkout the latest
released version of the kernel:

git checkout Ubuntu-2.6.27-7.14}}}

Once this is complete, you can keep your tree up-to-date by running this command:
git fetch}}}

'''** Warning **'''
Line 116: Line 65:
= Pushing changes to the main repo = == Pushing changes to the main repo ==
Line 121: Line 70:
= Commit templates = == Commit templates ==
Line 140: Line 89:
= Patch acceptance criteria = == Patch acceptance criteria ==
Line 153: Line 102:
= Developers with access to = == Developers with access to ==
Line 160: Line 109:
{{{     {{{
Line 170: Line 119:
{{{     {{{
Line 178: Line 127:
{{{     {{{
Line 180: Line 129:
*do work*
git send-pack<user>/my-git-tree.git master
git remote add zinc ssh://<user>/my-git-tree.git
<do work>
git push zinc
Line 186: Line 136:
{{{     {{{
Line 196: Line 146:
{{{     {{{
Line 204: Line 154:
{{{     {{{
Line 217: Line 167:
{{{     {{{


Git is the source code management tool used by the Linux kernel developer community. Ubuntu has adopted this tool for our own Linux kernel source code so that we can interact better with the community and the other kernel developers.

Current GIT Trees

All of the current live Ubuntu kernel repositories are at the URL below:


There is a tree for each of the currently supported releases as well as any open development and upcoming releases:

  • maverick












Typically the distro kernel is on the master branch in these repositories. A number of releases also have other Topic Branches which represent other related but divergent kernels for other purposes.

To find out what else is available try browsing and searching for ubuntu).

Installing GIT

To obtain the git binaries, simply install the git-core package:

  • sudo apt-get install git-core

Use apt-get because other tools such as aptitude will autoremove packages that have no install links.

Note that the git package is an entirely different tool which will not do what you want.

Obtaining the kernel sources for an Ubuntu release using git

The source for each release is maintained in its own git repository on Launchpad.

The git repository is listed in the Vcs-Git: header in the source package and is of the following form:

  • git://<source package>/+git/<series>

For example, the standard Cosmic kernel is available at:

  • git://

There is a tree for each of the currently supported releases as well as any open development and upcoming releases:

  • groovy






Replace your intended OS series in the above, and pull the source for the kernels you need.

The distro kernel is always on the master branch in these repositories. Each release also has a master-next branch containing the commits that will go onto the master branch and become the next release for that release.

A number of releases also have other source packages which represent other related but divergent kernels for other purposes. For example, there is a specialized AWS kernel available in the linux-aws source package. (Previously these sorts of things were done in Topic Branches and some older kernels and projects still use them.)

If you cannot use the git protocol (perhaps because of a firewall), you can use the slower http protocol. For example:

Obtaining a copy

To obtain a local copy you can simply git clone the repository for the release you are interested. The git command is part of the git package.

For example to obtain the Bionic tree:

  • git://

This will download several hundred megabytes of data. If you plan on working on more than one kernel release you can save space and time by downloading the upstream kernel tree. Note that once these two trees are tied together you cannot remove the virgin Linus tree without damage to the Ubuntu tree:

  • git clone git://
    git clone --reference linux git://

In each case you will end up with a new directory ubuntu-<release> containing the source and the full history which can be manipulated using the git command from within each directory.

By default you will have the latest version of the kernel tree, the master tree. You can switch to any previously released kernel version using the release tags. To obtain a full list of the tagged versions in the release as below:

  • $ git tag -l Ubuntu-*

To look at the Ubuntu-5.4.0-52.57 version you can simply checkout a new branch pointing to that version:

  • git checkout -b temp Ubuntu-5.4.0-52.57

You may then manipulate the release - for example, by adding new commits.

Maintaining local changes

During development, the kernel git repository is being constantly rebased against Linus' tree. IOW, Ubuntu specific changes are not being merged, but rather popped off, the tree updated to mainline, and then the Ubuntu specific changes reapplied; they are rebased. There are two ways to track the kernel git tree, depending on whether you have local changes or not:

No Local Changes

  • git fetch
    git reset --hard origin/master

Preserve Local Changes

  • git fetch
    git rebase --onto origin/master origin/master@{1}

Pushing changes to the main repo

Since the main repo is not publicly writable, the primary means for sending patches to the kernel team is using git format-patch. The output from this command can then be sent to the kernel-team mailing list.

Alternatively, if you have a publicly available git repository for which changes can be pulled from, you can use git request-pull to generate an email message to send to the kernel-team mailing list.

Commit templates

In debian/commit-templates/ there are several templates that must be used when committing changes that you expect to be integrated with the Ubuntu kernel repo. The commit templates contain comments for how to fill out the required information. Also note that all commits must have a Signed-off-by line (the "-s" option to git commit). A typical git commit command will look like:

  git commit -s -F debian/commit-templates/patch -e

Note that the -e (edit) option must follow the -F option, else git will not let you edit the commit-template before committing.

An example commit log will look like such:

  UBUNTU: scsi: My cool change to the scsi subsystem

  UpstreamStatus: Merged with 2.6.15-rc3

  My cool change to the scsi subsystem makes scsi transfers increase
  magically to 124GiB/sec.

  Signed-off-by: Joe Cool Hacker <>

Patch acceptance criteria

In general, Ubuntu will apply the same criteria applicable to upstream kernel. Here is a checklist of reading and tools related to posting kernel patches:

  • <kernel-directory>/Documentation/SubmittingPatches

  • <kernel-directory>/scripts/

  • <kernel-directory>/scripts/cleanpatch

  • <kernel-directory>/scripts/cleanfile

  • <kernel-directory>/scripts/Lindent

If you are creating a new file, it is helpful to run it through cleanfile and/or Linent before creating a patch
If you have generated a patch, it helps running it through and cleanpatch if necessary
Also, using the commit template described above is a good idea for Ubuntu-specific patches

Developers with access to

The kernel team has a git repo located on (AKA in /srv/

You can, if you want, create a clone for yourself in your directory, and just have your changes pulled when ready.

Suggested way to do this:

  • git clone -l -n -s /srv/
    vi ubuntu-jaunty/.git/description
    ( give it a descriptive name )
    mv ubuntu-jaunty/.git /srv/<user>/my-git-tree.git

You can now push your changes to this tree via ssh. Note the -l -n -s options do a few special things, mainly making your repo share objects with ours (saves space).

Now you need to run git update-server-info in your tree so that it is available over http transport

  • cd /srv/<user>/my-git-tree.git
    git update-server-info
    chmod +x /srv/<user>/my-git-tree.git/hooks/post-commit

To work on your branch, now clone to your local machine from the same origin tree (not the tree you just created on zinc -- this is only for pushing to):

  • git clone git:// my-tree
    git remote add zinc ssh://<user>/my-git-tree.git
    <do work>
    git push zinc maser

Suggested method for keeping this tree synced with the ubuntu tree, instead of git pull, is to do:

  • cd my-tree
    git fetch origin
    git rebase origin

This will keep your changes on top of the original tree (as opposed to being merged). This is also a good idea because during development (e.g. while following the upstream git repo), we frequently rebase to linux-2.6.git upstream, so the HEAD is not always suitable for pull/merge.

Git tips and tricks

Reordering patches

  • git rebase -i HEAD~10

allows you to interactively reorder the last 10 patches in your branch. You can also squash some patches together. Just follow the directions at the bottom of the file opened up on typing the command.


Setting up your $HOME/.gitconfig file can help reduce the number of arguments you need to specify to git commands, and let you specify commonly used remote repositories.

  • [user]
            email =
            name = "Steve Conklin"
            signingkey = 0x3A758A1E
    smtpuser =
    smtpserver = /usr/bin/msmtp

Is what I have in my file to set up my email address and email.

  • [remote "sconklin"]
            url = "ssh://"
            fetch = +refs/heads/*:refs/remotes/sconklin/*
    [remote "drm-2.6"]
            url = "git://"
            fetch = +refs/heads/*:refs/remotes/drm-2.6/*
    [remote "drm-intel"]
            url = "git://"
            fetch = +refs/heads/*:refs/remotes/drm-intel/*

Sets up the remote repositories that I use most often. With these in the config, I can "git fetch sconklin" in any repo and get that remote.

A google search for ".gitconfig" will turn up other useful settings.

More information

Please read the documentation included with the git-core package for more details on git commands. A tutorial is also available at

For a list of quick git recipes and examples, see KernelTeam/GitCheatSheet.

CategoryKernel CategoryDocumentation

KernelTeam/KernelGitGuide (last edited 2010-06-28 23:55:41 by c-76-105-148-120)