Development using git

From Alpine Linux
Revision as of 15:54, 4 July 2011 by Fab (talk | contribs) (Basic Git usage)
Jump to: navigation, search

This document describes how to use git for Alpine Linux development and related projects.

Basic Git usage

Configure your global git config

First you need to tell your name and email to git. This name and email will show up in all your commits.

git config --global "Your Name Comes Here" git config --global

Using git config without --global let you configure other details for a specific git repository.

Tip: If you want to use git with colored output use:

git config --global color.ui true

Email configuration

To be able send your commits (patches) via email you need configure an SMTP server.

git config --global sendemail.smtpserver

For sending from a gmail address you can do:

git config --global sendemail.smtpserver git config --global sendemail.smtpserverport 587 git config --global sendemail.smtpencryption tls git config --global sendemail.smtpuser

Optionally, it is possible to skip the password prompt by adding it to the configuration with:

git config --global sendemail.smtppass your_password

To reset CC mail attribute

git config --global sendemail.suppresscc all

Example ~/.gitconfig

        email =
        name = Your Name
        editor = nano
        pager = less -FXRS
        from = Your Name <>
        smtpuser =
	smtpserver =
	smtpencryption = tls
	smtpserverport = 587
	suppresscc = self

        default = simple

Cloning the repository via Git

git clone git://

The full aports repository is now copied to your aports/.git dir and the latest commit is checked out in aports/. Most operations you do from here will happen on your local copy and will not affect

If you want only the last 3 revisions:

git clone git:// --depth 3

git log

to see the full log of the trunk.

You can also browse the git repository via cgit.

General GIT Workflow

  1. Make your file edits in your local checkout of the local copy of repository.
  2. git commit the changes in your local repository
  3. git pull --rebase to bring the rest of your local repository up to date
  4. git log origin..master to check what you are going to commit
  5. git push to move your changes up to the master. This requires you have an ssh login and have cloned via ssh:// and not via git:// (see Development using git with write access)

git stash

if you want to "hide" your changes. Do this if you think there may be other commits against the same things you are working on and want to refresh your local checkout (using a git pull --rebase) from the master. Use git stash apply to get your stash back.

git checkout -f master

if you think your tree is pretty hopeless, need a kill-and-fill to bring the master into your local repository. You will lose local changes.

List the local branch

You can now list your local branch by doing

git branch

which should ouput

* master

List your local non committed changes

git status


Now you can start to work on your tree. As soon as you feel you have reached a step in developement where you can commit your work locally, use

git commit -a


git commit <specific files>


git add <specific files> git commit

If you wish to give credit to someone else's work (e.g. you are applying a third party patch):

git commit <specific files> --author "Name Surname <>

The format of the commit message should be:

One-line descrption thats less than 72 chars long
<second line empty>
Optional longer description with explanation why changes were made. Links to relevant issues
in bugtracker can be done with:

  ref #<issuenumber>

It is also possible to resolve issues with:

  fixes #<issuenumber>

Think of first line as the subject in an email and the third line and on as the body of the email, describing what the commit does. You dont need the long description but the first line, the short description should be there as it will be showed in the commit log.

List your commits

git log

Keeping your local working branch in sync

Pull the changes from upstream (

git pull --rebase

Documentation about git

Some other useful documents