From ArchWiki
Revision as of 13:20, 20 July 2011 by Stfn (talk | contribs)
Jump to: navigation, search

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki: Generally about contributing to pacman, although it still serves as a practical Git tutorial Template:Article summary wiki Template:Article summary end

Git is the version control system (VCS) coded by Linus Torvalds (the creator of the Linux kernel) after being criticized for using the proprietary BitKeeper with the Linux kernel. Git is now used to maintain sources for the Linux kernel as well as thousands of other projects, including Pacman, Arch's package manager.

There is extensive documentation, guides, and tutorials available from the official web site.


Template:Package Official can be installed with pacman as usual from the [extra] repository. Pay attention to the optional dependencies if you care about using Git with other VCS software, mail servers, or using Git's GUI.

Bash completion (eg. hitting tab to complete commands you are typing) should work if you

source /usr/share/git/completion/git-completion.bash

Alternatively, you can install the Template:Package Official package to load the completions automatically for new shells.

If you want to use Git's built-in GUI (eg. Template:Codeline or Template:Codeline) you should install the Template:Package Official package or you'll get a rather cryptic message:

/usr/bin/gitk: line 3: exec: wish: not found.


Git reads its configuration from a few INI type configuration files. In each git repository Template:Filename is used for configuration options specific to that repository. Per-user ("global") configuration in Template:Filename is used a s a fall-back from the repository configuration. You can edit the files directly but the preferred method is to use the git-config utility. For example,

 git config --global core.editor "nano -w"

adds Template:Codeline to the Template:Codeline section of your Template:Filename file.

The man page for the git-config utility has a fairly long list of variables which can be set.


Parts from everywhere, much from the wonderful tutorial here:

Additionally see Super Quick Git Guide.

Pull the network scripts with

git clone

Update an existing clone

git pull origin

Commit changes

git commit -a -m "changelog message"

To create a new branch

git branch somebranch

Change to a different branch

git checkout differentbranch

Merge a branch to current active branch

git merge somebranch

Delete a branch

git branch -d somebranch

Diff between two branches

git diff master..somebranch

Diff between two commit ID's (found in git log)

git diff e9780c7cba2855350e914fde227a79bb63c1351d..8b014e40346b38b3b9bfc41359b4e8a68e804c0d

Diff between the last two commits

git diff HEAD^ HEAD

Patchset between two branches (follows same syntax as git diff afaik)

git format-patch master..somebranch

Or better:

git format-patch -o out origin

Set nano as default editor

git config --global core.editor "nano -w"

Start remote repository [broken as of 31DEC10]

Git Smart HTTP (git-http-backend)

Since version 1.6.6 git is able to use the HTTP(S) protocol as efficiently as SSH or GIT. Furthermore it's not only possible to clone or pull from repositories, but also to push into repositories over HTTP(S).

The setup for this is rather simple as all you need to have installed is the Apache webserver (with mod_cgi, mod_alias, and mod_env enabled) and of course, git:

# pacman -S apache git

Once you have your basic setup up and running, add the following to your Apache's config usually located at /etc/httpd/conf/httpd.conf:

<Directory "/usr/lib/git-core*">
    Order allow,deny
    Allow from all

SetEnv GIT_PROJECT_ROOT /srv/git
ScriptAlias /git/ /usr/lib/git-core/git-http-backend/

The above example config assumes that your git repositories are located at /srv/git and that you want to access them via something like http(s)://your_address.tld/git/your_repo.git. Feel free to customize this to your needs.

Note: Of course you have to make sure that your Apache can read and write (if you want to enable push access) on your git repositories.

For more detailed documentation, visit the following links: