Development using git

From Alpine Linux
Revision as of 13:51, 9 September 2009 by Ncopa (talk | contribs) (added some basic usage for creating a new git repo)
Jump to: navigation, search

Git is now being used for version control of the alpine-baselayout and alpine-conf packages.

Configuring git

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 user.name "Your Name Comes Here"
git config --global user.email you@yourdomain.example.com

Git Clone

To get started, clone the git repository for the package you are interested in:

 git clone git://git.alpinelinux.org/alpine-baselayout
 git clone git://git.alpinelinux.org/alpine-conf

Make your changes.

To prepare a patch:

git diff > short-description-of-change.patch

This diff can be sent to alpine-devel@lists.alpinelinux.org mailing list.

Create new git repository for a new project

Start with creating a new directory. In this example the project will be named myproj.

mkdir myproj
cd myproj

Lets initialize the git repository. This will create the .git dir.

git init

Now create the initial files you want. In this example we just create hello.txt

echo "hello git" > hello.txt

We add this to the git "index" and commit it. The -v option shows the diff as a last reiew. Your $EDITOR will be opened and you will need to create a description of the initial commit.

git add hello.txt
git commit -v

The format of the commit message should be:

[first line]One-line descrption thats les than 72 chars long
[second line empty]
[third line]longer description.

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.

Now you can see the initial commit with:

git log

Make some more changes. In this example we just append some text to hello.txt

echo "hello again" >> hello.txt

To check what you have done since last commit use:

git log

To commit the change do:

git add hello.txt
git commit -v

or alternatively:

git commit -a -v

The separate git add is useful when you ave changed many files but just want commit some of the changed files.

Migrate a subversion repository to git

Start with creating a users.txt file where the svn users are mapped to an email address for git.

echo "ncopa = Natanael Copa <ncopa@example.com>" > users.txt

Create a temp work area.

mkdir proj-tmp

Init the git repository. If your svn repo does not have the standard trunk branches and tags dirs you shouldnt use the --stdlayout. You can also use -T trunk -b branches -t tags.

cd proj-tmp
git svn init svn://svn.alpinelinux.org/proj --stdlayout

Connect the users.txt to the empty git repository so users are remapped.

git config svn.authorsfile ../users.txt

Fetch and import the svn repository. This might take some time.

git fetch

Now we can create a bare repository and upload it to dev.alpinelinux.org/gitroot.

cd ..
git clone --bare proj-tmp proj.git
scp -r proj.git dev.alpinelinux.org:/gitroot

References

Some useful documents