Difference between revisions of "Git"

From ArchWiki
Jump to: navigation, search
(Heading level 1 is reserved for article titles. See Effective Use of Headers#Formatting.)
(Replaced poorly written note about bash color prompt with a simpler version. This article shouldn't be about bash color prompts, and therefore the example was removed.)
(45 intermediate revisions by 25 users not shown)
Line 1: Line 1:
[[Category: Development (English)]]
+
[[Category:Version Control System]]
 +
[[zh-CN:Git]]
 
{{Article summary start}}
 
{{Article summary start}}
 
{{Article summary text|Installing and using the Git VCS}}
 
{{Article summary text|Installing and using the Git VCS}}
Line 5: Line 6:
 
{{Article summary wiki|Super Quick Git Guide}}: Generally about contributing to pacman, although it still serves as a practical Git tutorial
 
{{Article summary wiki|Super Quick Git Guide}}: Generally about contributing to pacman, although it still serves as a practical Git tutorial
 
{{Article summary wiki|Gitweb}}
 
{{Article summary wiki|Gitweb}}
 +
{{Article summary wiki|Cgit}}
 +
{{Article summary wiki|Subversion}}
 +
{{Article summary wiki|Concurrent Versions System}}
 +
{{Article summary link|GitHub|https://github.com/}}
 
{{Article summary end}}
 
{{Article summary end}}
  
 
[http://git-scm.com/ 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.
 
[http://git-scm.com/ 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 [http://git-scm.com/documentation extensive documentation, guides, and tutorials available from the official web site].
+
There is extensive documentation, including guides and tutorials, available from the [http://git-scm.com/documentation official web site].
  
 
==Installation==
 
==Installation==
{{Package Official|git}} 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.
+
{{Pkg|git}} can be installed with [[pacman]] from the [[Official Repositories|official repositories]]. If you care about using Git with other VCS software, mail servers, or using Git's GUI, pay close attention to the optional dependencies.
  
Bash completion (eg. hitting tab to complete commands you are typing) should work if you
+
Bash completion (e.g. hitting {{keypress|Tab}} to complete commands you are typing) should work if you add this line to your {{ic|~/.bashrc}} file:
source /usr/share/git/completion/git-completion.bash
+
{{bc|source /usr/share/git/completion/git-completion.bash}}
Alternatively, you can install the {{Package Official|bash-completion}} package to load the completions automatically for new shells.
+
Alternatively, you can install the {{Pkg|bash-completion}} package to load the completions automatically for new shells.
  
If you want to use Git's built-in GUI (eg. {{codeline|gitk}} or {{codeline|git gui}}) you should install the {{Package Official|tk}} package or you'll get a rather cryptic message:
+
If you want to use Git's built-in GUI (eg. {{Ic|gitk}} or {{Ic|git gui}}) you should install the {{Pkg|tk}} package, or you will get a rather cryptic message:
/usr/bin/gitk: line 3: exec: wish: not found.
+
{{bc|/usr/bin/gitk: line 3: exec: wish: not found.}}
  
 
== Configuration ==
 
== Configuration ==
Git reads its configuration from a few INI type configuration files.  In each git repository {{filename|.git/config}} is used for configuration options specific to that repository.  Per-user ("global") configuration in {{filename|$HOME/.gitconfig}} 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 reads its configuration from a few INI type configuration files.  In each git repository {{ic|.git/config}} is used for configuration options specific to that repository.  Per-user ("global") configuration in {{ic|$HOME/.gitconfig}} is used as 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"
 
  $ git config --global core.editor "nano -w"
adds {{codeline|<nowiki>editor = nano -w</nowiki>}} to the {{codeline|<nowiki>[core]</nowiki>}} section of your {{filename|~/.gitconfig}} file.
+
adds {{Ic|<nowiki>editor = nano -w</nowiki>}} to the {{Ic|<nowiki>[core]</nowiki>}} section of your {{ic|~/.gitconfig}} file.
  
The [http://www.kernel.org/pub/software/scm/git/docs/git-config.html man page for the git-config] utility has a fairly long list of variables which can be set.
+
The [http://schacon.github.com/git/git-config.html man page for the git-config] utility has a fairly long list of variables which can be set.
  
 
Here are some more basic configurations you will probably want:
 
Here are some more basic configurations you will probably want:
Line 34: Line 39:
  
 
==Cheatsheet==
 
==Cheatsheet==
Parts from everywhere, much from the wonderful tutorial here: http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html
+
Parts from everywhere, much from the wonderful tutorial here: http://schacon.github.com/git/gittutorial.html
  
 
Additionally see [[Super Quick Git Guide]].
 
Additionally see [[Super Quick Git Guide]].
  
 
Pull the network scripts with
 
Pull the network scripts with
  git clone http://archlinux.org/~james/projects/network.git
+
  git clone <nowiki>git://projects.archlinux.org/netcfg.git</nowiki>
 
Update an existing clone
 
Update an existing clone
 
  git pull origin
 
  git pull origin
Line 58: Line 63:
 
Diff between two branches
 
Diff between two branches
 
  git diff master..somebranch
 
  git diff master..somebranch
Diff between two commit ID's (found in git log)
+
Diff between two commit IDs (found in git log)
 
  git diff e9780c7cba2855350e914fde227a79bb63c1351d..8b014e40346b38b3b9bfc41359b4e8a68e804c0d
 
  git diff e9780c7cba2855350e914fde227a79bb63c1351d..8b014e40346b38b3b9bfc41359b4e8a68e804c0d
 
Diff between the last two commits
 
Diff between the last two commits
Line 66: Line 71:
 
Or better: http://wiki.winehq.org/GitWine#head-f7a29e7ed999b5924748a60c5a1cd4a019032d26
 
Or better: http://wiki.winehq.org/GitWine#head-f7a29e7ed999b5924748a60c5a1cd4a019032d26
 
  git format-patch -o out origin
 
  git format-patch -o out origin
Set nano as default editor
+
Set [[nano]] as default editor
 
  git config --global core.editor "nano -w"
 
  git config --global core.editor "nano -w"
Start remote repository
+
 
http://www.adeal.eu/starting-with-git.php [broken as of 31DEC10]
+
==Git Prompt==
 +
The Git package comes with a prompt script. To enable the prompt addition you will need to source the git-prompt.sh script and add {{Ic|$(__git_ps1 " (%s)")}} to you PS1 variable.
 +
* Copy {{Ic|/usr/share/git/git-prompt.sh}} to your home directory (e.g. {{Ic|~/.git-prompt.sh}}).
 +
* Add the following line to your .bashrc/.zshrc:
 +
source ~/.git-prompt.sh
 +
* For Bash:
 +
PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
 +
{{Note|For information about coloring your bash prompt see [[Color_Bash_Prompt]]}}
 +
 
 +
* For zsh:
 +
PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
 +
 
 +
The {{Ic|%s}} is replaced by the current branch name. The git information is displayed only if you are navigating in a git repository. You can enable extra information by setting and exporting certain variables to a non-empty value as shown in the following table:
 +
 
 +
{| border="1"
 +
|+
 +
! Variable !! Information
 +
|-
 +
| GIT_PS1_SHOWDIRTYSTATE || '''*''' for unstaged and '''+''' for staged changes
 +
|-
 +
| GIT_PS1_SHOWSTASHSTATE || '''$''' if something is stashed
 +
|-
 +
| GIT_PS1_SHOWUNTRACKEDFILES || '''%''' if there are untracked files
 +
|}
 +
 
 +
In addition you can set the {{Ic|GIT_PS1_SHOWUPSTREAM}} variable to {{Ic|"auto"}} in order to see {{Ic|'''<'''}} if you are behind upstream, {{Ic|'''>'''}} if you are ahead and {{Ic|'''<>'''}} if you have diverged.
 +
 
 +
{{Note|If you experience that {{Ic|$(__git_ps1)}} return {{Ic|((unknown))}} then there's a {{Ic|.git}} folder in your current directory which doesn't contain any repository, and therefore Git does not recognize it. This can for example happen if you for some reason mistake Git's config-file to be {{Ic|~/.git/config}} instead of {{Ic|~/.gitconfig}}.}}
  
 
==Transfer Protocols==
 
==Transfer Protocols==
 
===Smart HTTP===
 
===Smart HTTP===
Since version 1.6.6 git is able to use the HTTP(S) protocol as efficiently as SSH or GIT by utilizing the git-http-backend. Furthermore it's not only possible to clone or pull from repositories, but also to push into repositories over HTTP(S).
+
Since version 1.6.6 git is able to use the HTTP(S) protocol as efficiently as SSH or GIT by utilizing the git-http-backend. Furthermore it is 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:
+
The setup for this is rather simple as all you need to have installed is the Apache web server (with mod_cgi, mod_alias, and mod_env enabled) and of course, git:
 
  # pacman -S apache 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 <code>/etc/httpd/conf/httpd.conf</code>:
+
Once you have your basic setup up and running, add the following to your Apache's config usually located at {{ic|/etc/httpd/conf/httpd.conf}}:
 
  <Directory "/usr/lib/git-core*">
 
  <Directory "/usr/lib/git-core*">
 
     Order allow,deny
 
     Order allow,deny
Line 88: Line 120:
 
  ScriptAlias /git/ /usr/lib/git-core/git-http-backend/
 
  ScriptAlias /git/ /usr/lib/git-core/git-http-backend/
  
The above example config assumes that your git repositories are located at <code>/srv/git</code> and that you want to access them via something like <code>http(s)://your_address.tld/git/your_repo.git</code>. Feel free to customize this to your needs.
+
The above example config assumes that your git repositories are located at {{ic|/srv/git}} and that you want to access them via something like <nowiki>http(s)://your_address.tld/git/your_repo.git</nowiki>. 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.}}
 
{{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.}}
Line 94: Line 126:
 
For more detailed documentation, visit the following links:
 
For more detailed documentation, visit the following links:
 
* http://progit.org/2010/03/04/smart-http.html
 
* http://progit.org/2010/03/04/smart-http.html
* http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html
+
* https://www.kernel.org/pub/software/scm/git/docs/v1.7.10.1/git-http-backend.html
  
 
===Git SSH===
 
===Git SSH===
You first need to have a public SSH key. For that follow the guide at [[Using SSH Keys]]. To setup SSH itself you need to follow the [[SSH]] guide. I assume you have a public SSH key now and your SSH is working.
+
You first need to have a public SSH key. For that follow the guide at [[Using SSH Keys]]. To set up SSH itself, you need to follow the [[SSH]] guide. This assumes you have a public SSH key now and that your SSH is working.
Open your SSH key in your favorite editor (default public key name is id_rsa.pub and is located in ~/.ssh) and copy it's content (CTRL + C).
+
Open your SSH key in your favorite editor (default public key name is {{ic|~/.ssh/id_rsa.pub}}), and copy its content ({{keypress|Ctrl+c}}).
Now go to your user where you have made your git repository, since we now need to allow that SSH key to login on that user to access the GIT repository.
+
Now go to your user where you have made your Git repository, since we now need to allow that SSH key to log in on that user to access the Git repository.
Open this file in your favorite editor (i use nano)
+
Open {{ic|~/.ssh/authorized_keys}} in your favorite editor, and paste the contents of id_rsa.pub in it. Be sure it is all on one line! That is important! It should look somewhat like this:
nano ~/.ssh/authorized_keys
+
and paste the contents of id_rsa.pub in it. Be sure it is all on one line! That is important! It should look somewhat like this:
+
 
{{Warning|Do not copy the line below! It is an example! It will not work if you use that line!}}
 
{{Warning|Do not copy the line below! It is an example! It will not work if you use that line!}}
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCboOH6AotCh4OcwJgsB4AtXzDo9Gzhl+BAHuEvnDRHNSYIURqGN4CrP+b5Bx/iLrRFOBv58TcZz1jyJ2PaGwT74kvVOe9JCCdgw4nSMBV44cy+6cTJiv6f1tw8pHRS2H6nHC9SCSAWkMX4rpiSQ0wkhjug+GtBWOXDaotIzrFwLw== username@hostname
+
<pre style='overflow:auto'>
Now you can checkout your git repo this way (change where needed. Here it's using the git username and localhost):
+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCboOH6AotCh4OcwJgsB4AtXzDo9Gzhl+BAHuEvnDRHNSYIURqGN4CrP+b5Bx/iLrRFOBv58TcZz1jyJ2PaGwT74kvVOe9JCCdgw4nSMBV44cy+6cTJiv6f1tw8pHRS2H6nHC9SCSAWkMX4rpiSQ0wkhjug+GtBWOXDaotIzrFwLw== username@hostname
 +
</pre>
 +
Now you can checkout your Git repository this way (change where needed. Here it is using the git username and localhost):
 
  git clone git@localhost:my_repository.git
 
  git clone git@localhost:my_repository.git
You should now get an SSH yes/no question. Type yes followed by enter. Then you should have your repository checked out. Since this is with SSH you also do have commit rights now. For that look at [[Git]] and [[Super Quick Git Guide]].
+
You should now get an SSH yes/no question. Type {{ic|yes}} followed by {{keypress|Enter}}. Then you should have your repository checked out. Because this is with SSH, you also do have commit rights now. For that look at [[Git]] and [[Super Quick Git Guide]].
  
===GIT Daemon===
+
====Specifying a non-standard port====
{{Note|The git daemon only allows read access. For write access look at "Git SSH".}}
+
Connecting on a port other than 22 can be configured on a per-host basis in {{ic|/etc/ssh/ssh_config}} or {{ic|~/.ssh/config}}. To set up ports for a repository, specify the path in {{ic|.git/config}} using the port number {{ic|N}} and the ''absolute path'' {{ic|/PATH/TO/REPO}}:
This will allow url's like "git clone git://localhost/my_repository.git".
+
ssh://user@example.org:N/PATH/TO/REPO
 +
Typically the repository resides in the home directory of the user which allows you to use tilde-expansion. Thus to connect on port N=443,
 +
url = git@example.org:repo.git
 +
becomes:
 +
url = ssh://git@example.org:443/~git/repo.git
  
Edit configuration file for git-dameon /etc/conf.d/git-daemon.conf (GIT_REPO is a place with your git projects), then start git-daemon with root privileges:
+
===Git Daemon===
/etc/rc.d/git-daemon start
+
{{Note|The git daemon only allows read access. For write access see [[#Git SSH]].}}
 +
This will allow URLs like "git clone git://localhost/my_repository.git".
  
To run the git-daemon every time at boot, just append git-deamon to DAEMONS line in /etc/rc.conf file.
+
Edit configuration file for git-daemon {{ic|/etc/conf.d/git-daemon.conf}} (GIT_REPO is a place with your git projects), then start git-daemon with root privileges:
 +
# rc.d start git-daemon
 +
 
 +
To run the git-daemon every time at boot, just append {{Ic|git-daemon}} to {{Ic|DAEMONS}} line in [[rc.conf]].
  
 
Clients can now simply use:
 
Clients can now simply use:
 
  git clone git://localhost/my_repository.git
 
  git clone git://localhost/my_repository.git
  
==References==
+
=== GIT repositories rights ===
* http://www.kernel.org/pub/software/scm/git/docs/
+
To restrict read/write access, you can simply use Unix rights, see http://sitaramc.github.com/gitolite/doc/overkill.html
* http://book.git-scm.com/index.html
+
 
* http://gitref.org/
+
For a fine-grained rights access, see [[gitolite]] and [[gitosis]]
* http://help.github.com/
+
 
 +
==See also==
 +
* [http://git-scm.com/book Pro Git book]
 +
* [http://gitref.org/ Git Reference]
 +
* https://www.kernel.org/pub/software/scm/git/docs/
 +
* https://help.github.com/

Revision as of 14:34, 15 November 2012

Summary help replacing me
Installing and using the Git VCS
Related
Super Quick Git Guide: Generally about contributing to pacman, although it still serves as a practical Git tutorial
Gitweb
Cgit
Subversion
Concurrent Versions System
GitHub

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, including guides and tutorials, available from the official web site.

Installation

git can be installed with pacman from the official repositories. If you care about using Git with other VCS software, mail servers, or using Git's GUI, pay close attention to the optional dependencies.

Bash completion (e.g. hitting Template:Keypress to complete commands you are typing) should work if you add this line to your ~/.bashrc file:

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

Alternatively, you can install the bash-completion package to load the completions automatically for new shells.

If you want to use Git's built-in GUI (eg. gitk or git gui) you should install the tk package, or you will get a rather cryptic message:

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

Configuration

Git reads its configuration from a few INI type configuration files. In each git repository .git/config is used for configuration options specific to that repository. Per-user ("global") configuration in $HOME/.gitconfig is used as 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 editor = nano -w to the [core] section of your ~/.gitconfig file.

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

Here are some more basic configurations you will probably want:

$ git config --global user.name "Firstname Lastname"
$ git config --global user.email "your_email@youremail.com"
$ git config --global color.ui true

Cheatsheet

Parts from everywhere, much from the wonderful tutorial here: http://schacon.github.com/git/gittutorial.html

Additionally see Super Quick Git Guide.

Pull the network scripts with

git clone git://projects.archlinux.org/netcfg.git

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

Push a local branch or tag to a remote repository

git push REMOTENAME BRANCHNAME

Delete a branch or tag in a remote repository

git push REMOTENAME :BRANCHNAME

Diff between two branches

git diff master..somebranch

Diff between two commit IDs (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: http://wiki.winehq.org/GitWine#head-f7a29e7ed999b5924748a60c5a1cd4a019032d26

git format-patch -o out origin

Set nano as default editor

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

Git Prompt

The Git package comes with a prompt script. To enable the prompt addition you will need to source the git-prompt.sh script and add $(__git_ps1 " (%s)") to you PS1 variable.

  • Copy /usr/share/git/git-prompt.sh to your home directory (e.g. ~/.git-prompt.sh).
  • Add the following line to your .bashrc/.zshrc:
source ~/.git-prompt.sh
  • For Bash:
PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
Note: For information about coloring your bash prompt see Color_Bash_Prompt
  • For zsh:
PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '

The %s is replaced by the current branch name. The git information is displayed only if you are navigating in a git repository. You can enable extra information by setting and exporting certain variables to a non-empty value as shown in the following table:

Variable Information
GIT_PS1_SHOWDIRTYSTATE * for unstaged and + for staged changes
GIT_PS1_SHOWSTASHSTATE $ if something is stashed
GIT_PS1_SHOWUNTRACKEDFILES % if there are untracked files

In addition you can set the GIT_PS1_SHOWUPSTREAM variable to "auto" in order to see < if you are behind upstream, > if you are ahead and <> if you have diverged.

Note: If you experience that $(__git_ps1) return ((unknown)) then there's a .git folder in your current directory which doesn't contain any repository, and therefore Git does not recognize it. This can for example happen if you for some reason mistake Git's config-file to be ~/.git/config instead of ~/.gitconfig.

Transfer Protocols

Smart HTTP

Since version 1.6.6 git is able to use the HTTP(S) protocol as efficiently as SSH or GIT by utilizing the git-http-backend. Furthermore it is 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 web server (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
</Directory>

SetEnv GIT_PROJECT_ROOT /srv/git
SetEnv GIT_HTTP_EXPORT_ALL
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:

Git SSH

You first need to have a public SSH key. For that follow the guide at Using SSH Keys. To set up SSH itself, you need to follow the SSH guide. This assumes you have a public SSH key now and that your SSH is working. Open your SSH key in your favorite editor (default public key name is ~/.ssh/id_rsa.pub), and copy its content (Template:Keypress). Now go to your user where you have made your Git repository, since we now need to allow that SSH key to log in on that user to access the Git repository. Open ~/.ssh/authorized_keys in your favorite editor, and paste the contents of id_rsa.pub in it. Be sure it is all on one line! That is important! It should look somewhat like this:

Warning: Do not copy the line below! It is an example! It will not work if you use that line!
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCboOH6AotCh4OcwJgsB4AtXzDo9Gzhl+BAHuEvnDRHNSYIURqGN4CrP+b5Bx/iLrRFOBv58TcZz1jyJ2PaGwT74kvVOe9JCCdgw4nSMBV44cy+6cTJiv6f1tw8pHRS2H6nHC9SCSAWkMX4rpiSQ0wkhjug+GtBWOXDaotIzrFwLw== username@hostname

Now you can checkout your Git repository this way (change where needed. Here it is using the git username and localhost):

git clone git@localhost:my_repository.git

You should now get an SSH yes/no question. Type yes followed by Template:Keypress. Then you should have your repository checked out. Because this is with SSH, you also do have commit rights now. For that look at Git and Super Quick Git Guide.

Specifying a non-standard port

Connecting on a port other than 22 can be configured on a per-host basis in /etc/ssh/ssh_config or ~/.ssh/config. To set up ports for a repository, specify the path in .git/config using the port number N and the absolute path /PATH/TO/REPO:

ssh://user@example.org:N/PATH/TO/REPO

Typically the repository resides in the home directory of the user which allows you to use tilde-expansion. Thus to connect on port N=443,

url = git@example.org:repo.git

becomes:

url = ssh://git@example.org:443/~git/repo.git

Git Daemon

Note: The git daemon only allows read access. For write access see #Git SSH.

This will allow URLs like "git clone git://localhost/my_repository.git".

Edit configuration file for git-daemon /etc/conf.d/git-daemon.conf (GIT_REPO is a place with your git projects), then start git-daemon with root privileges:

# rc.d start git-daemon

To run the git-daemon every time at boot, just append git-daemon to DAEMONS line in rc.conf.

Clients can now simply use:

git clone git://localhost/my_repository.git

GIT repositories rights

To restrict read/write access, you can simply use Unix rights, see http://sitaramc.github.com/gitolite/doc/overkill.html

For a fine-grained rights access, see gitolite and gitosis

See also