Git

From Alpine Linux
Revision as of 09:06, 6 August 2010 by Ncopa (talk | contribs) (removed the svn migration stuff to separate doc)

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.

Publish the new repo to git.alpinelinux.org

make a 'bare' copy of your git repository.

cd ..
git clone --bare myproj myrepo.git

Copy that to git.alpinelinux.org. You need an ssh account for this.

scp -r myproj.git git.alpinelinux.org:

Send an email to Natanael Copa (or ping him on irc) to make a symlink of it to /gitroot on and to make it visible from cgit.

Now you can clone the remote repository from git.alpinelinux.org. First you have to remove the old myproj directory. Then you clone it with ssh.

mv myproj myproj.backup
git clone ssh://git.alpinelinux.org/~/myproj.git

Now you have a local copy of the remote repository in myproj/ directory. You can make changes there as much as you want. You can make commits, tags, undo/redo commits/tags (thats not pushed). You can do that without even having internet access. When you want to submit your changes (all you commits since last pull) you do:

git push


References

If you are a developer with ssh access (with permissions) you might want to take a look at these docs:

Some other useful documents