git/list[1] front-page[2] threads[3] people[4] search[5] about
 

How to set up a shared repository

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 21, 2005, 18:27 UTC
Message-ID
<Pine.LNX.4.63.0512211919040.16640@wbgn013.biozentrum.uni-wuerzburg.de>
Hi,

I installed a shared git repository in the last few days and this is the result. May it be useful!

Ciao, Dscho

---
[Note: this text assumes you have applied the core.umask patch]

So, there you are. You know CVS (or at least its concepts), and you want to set up a shared repository.

A. Setting up the umask
1. Separate repository box

If you are lucky enough that you can afford a separate machine for the shared repository: Good. Just make sure that the umask is set group friendly, either by ensuring that (assuming the login shell is bash) $HOME/.bash_profile contains the line

	umask 0002
or by using git-shell, which you have modified by inserting
	umask(0002);
at the start of main().
2. Some server accessible by ssh

If there are valid reasons not to set umask (maybe you want to allow other uses of that machine), or if you just do not want to go through the hassle to find out which scripts your login shell executes at startup, you just have to

	git-repo-config core.umask 0002
B. Making sure the index is not corrupted by a push
1. No checkout!

You can use the shared repository just like you use CVS: no working directory. To disallow a checkout, just do

	touch .git/index
	chmod a-rwx .git/index

Every attempt to modify the index (which is invalid), will now result in an error.

2. Ensure index and working directory consistency (no locking)

If you want to be able to work on the project in the shared repository, create hooks, as follows:

	test -d .git/hooks || mkdir .git/hooks
	cat > .git/hooks/update << EOF
	#!/bin/sh
	
	# if the working directory contains modifications, do not allow push
	HEAD=$(git-symbolic-ref HEAD)
	case "$1" in
	$HEAD)
	        unset GIT_DIR
	        cd .. && test -z "$(git-diff-index --name-only HEAD)";;
	esac
	EOF
	chmod a+x .git/hooks/update
	cat > .git/hooks/post-update << EOF
	#!/bin/sh
	
	# checkout HEAD, and build
	HEAD=$(git-symbolic-ref HEAD)
	case "$1" in
	$HEAD)
	        unset GIT_DIR
		umask 0002
		cd .. && git checkout -f HEAD && make;;
	esac
	EOF
	chmod a+x .git/hooks/post-update

This assumes that your project contains a Makefile, and that the tools necessary to build are installed on the repository server.

Note that I did not check if a push locks another push.
Next: Junio C Hamano
Message 1 of 3 in “How to set up a shared repository”
  1. Johannes SchindelinDec 21, 2005
  2. Junio C HamanoDec 21, 2005
  3. Johannes SchindelinDec 21, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.