Development using git: Difference between revisions

From Alpine Linux
No edit summary
No edit summary
 
(44 intermediate revisions by 13 users not shown)
Line 1: Line 1:
[http://git.or.cz Git] is now being used for version control of the [http://dev.alpinelinux.org/cgit/cgit.cgi/alpine-baselayout/ alpine-baselayout] and [http://dev.alpinelinux.org/cgit/cgit.cgi/alpine-conf alpine-conf] packages.
{{Move|Git|All git development articles should be consolidated}}


== Git Clone  ==
This document describes how to use [https://git-scm.com git] for Alpine Linux development and related projects. If you just want to browse the Alpine git repositories, please visit [https://git.alpinelinux.org/aports git.alpinelinux.org].


To get started, clone the [http://dev.alpinelinux.org/cgit git repository] for the package you are interested in:
== Basic Git usage ==


  git clone git://git.alpinelinux.org/alpine-baselayout
{{:Development_using_git:Configuration}}
  git clone git://git.alpinelinux.org/alpine-conf


Make your changes.  
{{Tip| If you want to use git with colored output use:
{{Cmd|git config --global color.ui true
git config --global core.pager more}}
}}


To prepare a patch:  
{{Tip| If you want to use git with proxy server:
{{Cmd|git config --global http.proxy <nowiki>http://proxy_ip:proxy_port</nowiki>}}
}}


git diff &gt; short-description-of-change.patch
== Cloning a repository via Git ==


This diff can be sent to [mailto:alpine-devel@lists.alpinelinux.org alpine-devel@lists.alpinelinux.org] mailing list.
There are two ways to work with the Alpine git repository...


== Migrate a subversion repository to git  ==
* ...without write access.
* ...with write access.


Start with creating a users.txt file where the svn users are mapped to an email address for git.  
[https://git.alpinelinux.org/aports git.alpinelinux.org] shows all available Alpine git repositories.


echo "ncopa = Natanael Copa &lt;ncopa@example.com&gt;" &gt; users.txt
=== Without write access ===


Create a temp work area.  
If you want to clone the Alpine aports repository, switch to the directory you want to have the ''aports/'' directory in and launch git.
{{Cmd|git clone <nowiki>git://git.alpinelinux.org/aports.git</nowiki>}}


  mkdir proj-tmp
{{Tip| If you are using proxy server:
  {{Cmd|git clone https://git.alpinelinux.org/aports}}
}}


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.
If you want only the last 3 revisions:


cd proj-tmp
{{Cmd|git clone <nowiki>git://git.alpinelinux.org/aports.git</nowiki> --depth 3}}
git svn init svn://svn.alpinelinux.org/proj --stdlayout


Connect the users.txt to the empty git repository so users are remapped.  
Use the command below to see the full log of the trunk.  


git config svn.authorsfile ../users.txt
{{Cmd|git log}}


Fetch and import the svn repository. This might take some time.
=== Submitting work without write access ===


git fetch
You can still [https://wiki.alpinelinux.org/wiki/Creating_patches submit a patch] without write access to the Alpine repository. For this you need to create an account on Alpine's GitLab, fork the desired repository (the fork resides on the server), clone the fork on your computer, make your changes into a separate branch, push the squashed branch to the fork (as branch; do not merge/rebase it into the master!) and create a merge request for that branch through the GitLab Web GUI.


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


cd ..
If you have write access to the Alpine repository, the URL needs to be adjusted for cloning a repository
git clone --bare proj-tmp proj.git
scp -r proj.git dev.alpinelinux.org:/gitroot


== References  ==
{{Cmd|git clone git@git.alpinelinux.org:aports}}


Some useful documents
Alternatively you can set the remote url of an exisiting git clone:
{{Cmd|git remote set-url origin git@git.alpinelinux.org:aports}}


*[http://git.or.cz/course/svn.html Git - SVN Crash Course] (quickstart if you know svn)
== General GIT Workflow ==
*[http://cworth.org/hgbook-git/tour/ A tour of git: the basics] '''Recommended'''
# Make your file edits in your local checkout of the local copy of repository.
*[http://book.git-scm.com/ The Git Community Book]  
# Commit the changes in your local repository: {{Cmd|git commit}}
*[http://www.newartisans.com/blog/2008/04/git-from-the-bottom-up.html Git from the bottom up]
# Bring the rest of your local repository up to date: {{Cmd|git pull --rebase}}
# Check what you are going to push: {{Cmd|git log origin..master}}
# Move your changes up to the master if you have write access {{Cmd|git push}} or [[Creating_patches|create a patch]] if not.
 
== Other related articles ==
 
* [[Development_using_git:Basic_usage| Basic usage]]
* [[Package Maintainers]]
* [[Creating patches]]
* [[Development_using_git:Developer_repositories|Developer repositories]]
* [[Development_using_git:Cgit| Using Cgit]]
* [[Development using git:Quality assurance]]
* [[Gitolite]]
 
== Further reading ==
{{:Development_using_git:Documentation}}
 
[[Category:Development]]
[[Category:Git]]

Latest revision as of 06:47, 23 August 2023

This page is proposed for moving ...

It should be renamed to Git. All git development articles should be consolidated (Discuss)

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 git.alpinelinux.org.

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 git config --global core.pager more

Tip: If you want to use git with proxy server:

git config --global http.proxy http://proxy_ip:proxy_port

Cloning a repository via Git

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

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

git.alpinelinux.org shows all available Alpine git repositories.

Without write access

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

Tip: If you are using proxy server:

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

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

Submitting work without write access

You can still submit a patch without write access to the Alpine repository. For this you need to create an account on Alpine's GitLab, fork the desired repository (the fork resides on the server), clone the fork on your computer, make your changes into a separate branch, push the squashed branch to the fork (as branch; do not merge/rebase it into the master!) and create a merge request for that branch through the GitLab Web GUI.

With write access

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

git clone git@git.alpinelinux.org:aports

Alternatively you can set the remote url of an exisiting git clone:

git remote set-url origin git@git.alpinelinux.org:aports

General GIT Workflow

  1. Make your file edits in your local checkout of the local copy of repository.
  2. Commit the changes in your local repository:

    git commit

  3. Bring the rest of your local repository up to date:

    git pull --rebase

  4. Check what you are going to push:

    git log origin..master

  5. Move your changes up to the master if you have write access

    git push

    or create a patch if not.

Other related articles

Further reading