Git: Difference between revisions

From Alpine Linux
No edit summary
mNo edit summary
Line 37: Line 37:


{{Cmd|git clone ssh://username@git.alpinelinux.org/aports.git}}
{{Cmd|git clone ssh://username@git.alpinelinux.org/aports.git}}
-----------


== General GIT Workflow ==
== General GIT Workflow ==
Line 48: Line 45:
# ''git push''    to move your changes up to the master. This requires you have an ssh login and have cloned via ssh://git.alpinelinux.org and not via git://git.alpinelinux.org. (see [[Development using git with write access]])
# ''git push''    to move your changes up to the master. This requires you have an ssh login and have cloned via ssh://git.alpinelinux.org and not via git://git.alpinelinux.org. (see [[Development using git with write access]])


{{Cmd|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 Push (Distributed Workflows) ==
 
If working with [http://book.git-scm.com/3_distributed_workflows.html Distributed Workflows] you would 'pull' from public repo, 'push' to another publically accessable repo ''(where you have write access)'', main developer ''(who has write access to public repo)'' 'pulls' you changes from your pub.accessed.repo into the public repo.  
{{Cmd|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
{{Cmd|git branch}}
which should ouput
* master
 
== List your local non committed changes ==
{{Cmd|git status}}
 
== Commit ==
Now you can start to work on your tree. As soon as you feel you have reached a step in development where you can commit your work '''locally''', use
{{Cmd|git commit -a}}
or
{{Cmd|git commit <specific files>}}
or
{{Cmd|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):
{{Cmd|git commit <specific files> --author "Name Surname <user@example.com>}}
 
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 ==
{{Cmd|git log}}


To make it easier for you to work, you can configure 'git push' to push your work to your publically accessable repo ''('git pull' would still pull from same repo as you cloned from)''.
{{cmd|cd /your/private/repo/where/you/work/reponame
git config remote.origin.pushurl "ssh://user@dev.alpinelinux/home/user/cgit/reponame.git"}}
Now 'git pull' pulls the public repo, and 'git push' pushes to '''your''' public repo.
{{Note|The path where you want to push to should first be prepared with 'git clone --bare ...' as described below in section 'Upload the new project'}}


== Keeping your local working branch in sync ==
== Other related articles ==
Pull the changes from upstream (git.alpinelinux.org)
{{Cmd|git pull --rebase}}


= Documentation about git =
* [[Development_using_git:Basic_usage| Basic usage]]
Some other useful documents
* [[Development_using_git:Documentation| Documentation]]
*[http://www.kernel.org/pub/software/scm/git/docs/ Git Tutorial]
* [[Development_using_git:Cgit| Cgit]]
*[http://git.or.cz/course/svn.html Git - SVN Crash Course] (quickstart if you know svn)
*[http://cworth.org/hgbook-git/tour/ A tour of git: the basics] '''Recommended'''
*[http://book.git-scm.com/ The Git Community Book]
* [http://wiki.sourcemage.org/Git_Guide Very good Git guide]


[[Category:Development]]
[[Category:Development]]

Revision as of 17:06, 4 July 2011

This document describes how to use git for Alpine Linux development and related projects. If you just want to browse the Alpine git repositories, please visit cgit.

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

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

Development using git:Email

Cloning the repository via Git

There are two ways to work with the Alpine git repository...

  • ...without write access.
  • ...with write access.

Without write access

cgit shows all available Alpine git repositories. If you want to clone the Alpine aports repository, switch to the directory you want to have the aports/ directory in and launch git.

git clone git://git.alpinelinux.org/aports.git

If you want only the last 3 revisions:

git clone git://git.alpinelinux.org/aports.git --depth 3

Use the command below to see the full log of the trunk.

git log

With write access

If you have write access to the Alpine the URL needs to be adjusted for cloning a repository

git clone ssh://username@git.alpinelinux.org/aports.git

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://git.alpinelinux.org and not via git://git.alpinelinux.org. (see Development using git with write access)

Git Push (Distributed Workflows)

If working with Distributed Workflows you would 'pull' from public repo, 'push' to another publically accessable repo (where you have write access), main developer (who has write access to public repo) 'pulls' you changes from your pub.accessed.repo into the public repo.

To make it easier for you to work, you can configure 'git push' to push your work to your publically accessable repo ('git pull' would still pull from same repo as you cloned from).

cd /your/private/repo/where/you/work/reponame git config remote.origin.pushurl "ssh://user@dev.alpinelinux/home/user/cgit/reponame.git"

Now 'git pull' pulls the public repo, and 'git push' pushes to your public repo.

Note: The path where you want to push to should first be prepared with 'git clone --bare ...' as described below in section 'Upload the new project'

Other related articles