Initial setup

If you haven’t yet successfully downloaded the source and generated a build of LineageOS, make sure you are familiar with those steps. Information on doing a build is available in the build guide for your device.

Setup an account on Gerrit and configure your Gerrit username in the Gerrit portal under Settings -> HTTP Password. Then, make sure your local git username matches with your Gerrit username::

git config --global "gerrit username"

If you already have SSH keys set up (e.g. for GitHub), skip the following steps.

Generate SSH keys,[1] and copy/paste to your Gerrit account under Settings -> SSH Public Keys:

ssh-keygen -t rsa -C ""

Make sure your keys are added to your ssh agent:

eval `ssh-agent -s`
ssh-add ~/.ssh/id_rsa

The steps above have to be performed only once.

Preparing the build environment

Go to the root of the source code:

cd ~/android/lineage

Setup your build environment:

source build/

The rest of this guide will rely on this being done. You can check the proper execution of the commands by typing:


Your shell will then navigate to the root of the sources, ~/android/lineage or give an error.

Submitting to Gerrit

Uploading your changes

First, you need to start a topic branch. This ‘branch’ holds the changes you make to the files on your computer that you will ultimately send to the LineageOS’s Gerrit instance for review. Create your topic branch:

repo start <branch name> <project path>

Change to the project (directory) that contains the file(s) you want to edit:

cd path/to/project

Do all the changes you need.

After you make your changes, you can commit them just as you normally would:

git add <file you edited>
git commit

Now you can upload your changes to Gerrit:

repo upload .

That’s it! Your change will be reviewed and may be accepted or rejected. See #Example_cases below for an example.

Submitting patch sets

It can happen that your submitted patch has issues or errors, which are noted in the code review, so you will want to resolve them. Sometimes it’s just tabs instead of spaces or typos in strings and variable names. To avoid some formal mistakes, make sure you’re familiar with the Android code style. For Eclipse users, just follow the instructions in development/ide/eclipse/README.importing-to-eclipse.txt.

Before you edit those files, make sure you are on the correct branch:

git branch

If you are not or in no branch at all, switch to the correct branch:

git checkout [branchname]

Now you can edit the files you want. After that, do the usual git status and notice that git diff will only show you the changes you just made. Make sure you add the files that you’ve modified by using git add. Once you’re satisfied, prepare the upload, by amending your commit:

git commit --amend

This will open an editor with your initial commit message. You can change the commit message if you want to, but make sure the last two lines stay as are as it contains the initial change ID and a blank line. With this id, Gerrit will detect your upload as a patch set and not as a new patch.

You can do git log and git status again. Notice how git handles your initial commit and the amended commit as one single patch. As for git show, it shows you all the changes made on that commit.

Finally, you can submit your patch set to your initial patch by typing:

repo upload .

Example cases


Let’s say you want to make a change in that resides in the frameworks/base project, and upload that to Gerrit for review. Start a local branch of that repo (directory) and call it mychanges:

cd frameworks/base
repo start mychanges .

Make the edits to that file. You can check those changes:

git add -n

If the results are acceptable, stage the modified file:

git add

Then commit it:

git commit -m 'Added feature xyz'

Issue the upload:

repo upload .

You should be asked a few questions and your commit should then be uploaded to Gerrit for review.

Add AWEXT Support

Start the new branch:

cd external/wpa_supplicant
repo start mychanges-wpa_supplicant .

Make changes, edit a few files, add new drivers.. etc.

git add *
git commit -am 'Added AWEXT drivers'
repo upload .


[1] If you get a “Permission denied (publickey)” error and you’re sure that everything is right, try using a DSA key instead of RSA.

ssh-keygen -t dsa -C "<email>@<server>.<domain>"

Getting your submission reviewed/merged

All submitted patches go through a code review process prior to merger. In addition to getting reviewed by your peers, selected project members have the capability to merge your code into LineageOS (to make sure they get informed, add one or more responsible reviewers to your change). To see a breakdown of who is responsible for the various areas, please see the list of LineageOS contributors.

Common commands

See Git Immersion for more information.




Git Immersion

Using git and repo

Gerrit Documentation