Difference between revisions of "Development using git"

From Alpine Linux
Jump to: navigation, search
m (Other related articles)
(With write access)
 
(23 intermediate revisions by 8 users not shown)
Line 1: Line 1:
This document describes how to use [http://git-scm.com git] for Alpine Linux development and related projects. If you just want to browse the Alpine git repositories, please visit [http://git.alpinelinux.org/cgit/aports cgit].
+
{{Move|Git|All git development articles should be consolidated}}
 +
 
 +
This document describes how to use [http://git-scm.com git] for Alpine Linux development and related projects. If you just want to browse the Alpine git repositories, please visit [http://git.alpinelinux.org/cgit/aports git.alpinelinux.org].
  
 
== Basic Git usage ==
 
== Basic Git usage ==
Line 6: Line 8:
  
 
{{Tip| If you want to use git with colored output use:
 
{{Tip| If you want to use git with colored output use:
  {{Cmd|git config --global color.ui true}}
+
  {{Cmd|git config --global color.ui true
 +
git config --global core.pager more}}
 +
}}
 +
 
 +
{{Tip| If you want to use git with proxy server:
 +
{{Cmd|git config --global http.proxy http://proxy_ip:proxy_port}}
 
}}
 
}}
  
 
{{:Development_using_git:Email}}
 
{{:Development_using_git:Email}}
  
== Cloning the repository via Git ==
+
== Cloning a repository via Git ==
  
 
There are two ways to work with the Alpine git repository...
 
There are two ways to work with the Alpine git repository...
Line 17: Line 24:
 
* ...without write access.
 
* ...without write access.
 
* ...with write access.
 
* ...with write access.
 +
 +
[http://git.alpinelinux.org/cgit/aports git.alpinelinux.org] shows all available Alpine git repositories.
  
 
=== Without write access ===
 
=== Without write access ===
  
[http://git.alpinelinux.org/cgit/aports 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.
+
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 git://git.alpinelinux.org/aports.git}}
 
{{Cmd|git clone git://git.alpinelinux.org/aports.git}}
 +
 +
{{Tip| If you are using proxy server:
 +
{{Cmd|git clone http://git.alpinelinux.org/cgit/aports}}
 +
}}
  
 
If you want only the last 3 revisions:
 
If you want only the last 3 revisions:
Line 34: Line 47:
 
=== With write access ===
 
=== With write access ===
  
If you have write access to the Alpine the URL needs to be adjusted for cloning a repository
+
If you have write access to the Alpine repository, the URL needs to be adjusted for cloning a repository
  
{{Cmd|git clone ssh://username@git.alpinelinux.org/aports.git}}
+
{{Cmd|git clone git@git.alpinelinux.org:aports}}
 +
 
 +
Alternatively you can set the remote url of an exisiting git clone:
 +
{{Cmd|git remote set-url origin git@git.alpinelinux.org:aports}}
  
 
== General GIT Workflow ==
 
== General GIT Workflow ==
 
# Make your file edits in your local checkout of the local copy of repository.
 
# Make your file edits in your local checkout of the local copy of repository.
# ''git commit''      the changes in your local repository
+
# Commit the changes in your local repository: {{Cmd|git commit}}
# ''git pull --rebase''  to bring the rest of your local repository up to date
+
# Bring the rest of your local repository up to date: {{Cmd|git pull --rebase}}
# ''git log origin..master'' to check what you are going to commit
+
# Check what you are going to push: {{Cmd|git log origin..master}}
# ''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]])
+
# Move your changes up to the master if you have write access {{Cmd|git push}} or [[Creating_patches|create a patch]] if not.
 
 
== 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.
 
 
 
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'}}
 
  
 
== Other related articles ==
 
== Other related articles ==
  
 
* [[Development_using_git:Basic_usage| Basic usage]]
 
* [[Development_using_git:Basic_usage| Basic usage]]
 +
* [[Package Maintainers]]
 
* [[Creating patches]]
 
* [[Creating patches]]
* [[Development_using_git:Cgit| Cgit]]
+
* [[Development_using_git:Developer_repositories|Developer repositories]]
* [[Development_using_git:Documentation| Documentation]]
+
* [[Development_using_git:Cgit| Using Cgit]]
 +
* [[Development using git:Quality assurance]]
 +
* [[Gitolite]]
 +
 
 +
== Further reading ==
 +
{{:Development_using_git:Documentation}}
  
 
[[Category:Development]]
 
[[Category:Development]]
 +
[[Category:Git]]

Latest revision as of 15:02, 30 April 2019

Tango-go-next.png
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

Email configuration

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

git config --global sendemail.smtpserver smtp.exmaple.com

For sending from a gmail address you can do:

git config --global sendemail.smtpserver smtp.gmail.com git config --global sendemail.smtpserverport 587 git config --global sendemail.smtpencryption tls git config --global sendemail.smtpuser your_email@gmail.com

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

[user]
        email = user@gmail.com
        name = Your Name
[core]
        editor = nano
        pager = less -FXRS
[sendemail]
        from = Your Name <user@gmail.com>
        smtpuser = user@gmail.com
	smtpserver = smtp.googlemail.com
	smtpencryption = tls
	smtpserverport = 587
	suppresscc = self

[push]
        default = simple

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 http://git.alpinelinux.org/cgit/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

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