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 package comes with a bash completion file. This file, also contains the necessary functions to provide git information on your bash or zsh shell prompt. To enable it add {{Ic|$(__git_ps1 " (%s)")}} to you PS1 variable.

+

The {{pkg|git}} package comes with a Bash completion file. This file also contains the necessary functions to provide Git information on your Bash or zsh shell prompt. To enable it add {{Ic|$(__git_ps1 " (%s)")}} to you PS1 variable.

−

* For bash:

+

* For Bash:

PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '

PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '

* For zsh:

* For zsh:

PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '

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:

+

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"

{| border="1"

Line 99:

Line 99:

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.

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.

Git Prompt

The git package comes with a Bash completion file. This file also contains the necessary functions to provide Git information on your Bash or zsh shell prompt. To enable it add $(__git_ps1 " (%s)") to you PS1 variable.

For Bash:

PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '

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 do not use Bash completion consider sourcing /usr/share/git/completion/git-completion.bash in your ~/.bashrc/~/.zshrc.

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 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:

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.

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.
Open your SSH key in your favorite editor (default public key name is id_rsa.pub and is located in ~/.ssh) and copy its content (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.
Open this file in your favorite editor (i use nano)

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!

Now you can checkout your git repo 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 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.

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: