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

Re: New to git: sorry for obvious question.

From
LRLuciano Rocha <luciano@eurotux.com>
Date
Feb 4, 2008, 10:50 UTC
Message-ID
<20080204105006.GA15855@bit.office.eurotux.com>
In-Reply-To
<47A6E130.7090909@glidos.net>
On Mon, Feb 04, 2008 at 09:56:00AM +0000, Paul Gardiner wrote:
Show 12 quoted lines
>  Hi,
> 
>  I've moved a project from CVS on sourceforge to git on repo.or.cz.  I
>  want a local mirror on my own home server, so that it appears amongst
>  the projects shown by my own gitweb set up, and so it gets caught by
>  my backup system.  I've created the mirror with
> 
>    git clone --bare <remote-url> <local-dir>
> 
>  and that seems fine.  But how do I now keep it up to date.  I was
>  guessing a cron job doing some sort of git pull, but pull doesn't
>  look to work on --bare proj.git type repositories.

You want git fetch. Git pull also updates the working copy, which you don't have.

Also, git clone --bare doesn't set up the origin configuration, and I
have to do it by hand:
  git config remote.origin.url "$url"
  git config remote.origin.fetch "+refs/heads/*:refs/heads/*"

As for keeping clones up to date, I include a script I use daily for that purpose.

-- 
Luciano Rocha <luciano@eurotux.com>
Eurotux Informática, S.A. <http://www.eurotux.com/>


#!/bin/bash

cd /media/stuff/src || exit 1

lockf=/tmp/.uprepo.lock
lockfile -60 -l 36000 -r 20 $lockf || exit 1

TL=$((20*60))

running()
{
	kill -0 $* &> /dev/null
}

tl()
{
	local max=$(($1+SECONDS))
	shift
	exec "$@" &
	while running $! &> /dev/null && [ $max -ge $SECONDS ]; do sleep 1; done
	if running $!; then
		kill $! &> /dev/null
		sleep 1
		kill -9 $! &> /dev/null
	fi
}

trap "rm -f $lockf" EXIT

shopt -s dotglob

for i in *.git */*.git; do
	[ -h "$i" ] && continue
	[ -d "$i" ] || continue

	d="${i%/.git}"

	echo $d
	if [ "$d" = "$i" ]; then
		(cd "$d" && tl $TL git fetch) 2>&1 | nocr
	elif [ -d "$i/svn" ]; then
		(cd "$d" && tl $TL git svn fetch) 2>&1 | nocr
	elif [ -e "$d/.cvsurl" ]; then
		(cd "$d" && tl $TL git cvsimport $(<.cvsurl)) 2>&1 | nocr
	elif [ -e "$d/.svnurl" ]; then
		(cd "$d" && tl $TL git svnimport -r $(<.svnurl)) 2>&1 | nocr
	else
		(cd "$d" && tl $TL git pull) 2>&1 | nocr
	fi
done

for i in */*.hg */*/*.hg; do
	[ -h "$i" ] && continue
	[ -d "$i" ] || continue

	d="${i%/.hg}"

	echo $d
	(cd "$d" && tl $TL hg pull)
done

for i in */*_darcs; do
	[ -h "$i" ] && continue
	[ -d "$i" ] || continue

	d="${i%/_darcs}"

	echo $d
	(cd "$d" && tl $TL darcs pull -aq)
done

for i in */.svn; do
	[ -h "$i" ] && continue
	[ -d "$i" ] || continue

	d="${i%/.svn}"

	echo $d
	(cd "$d" && tl $TL svn up -q)
done

for i in */CVS; do
	[ -h "$i" ] && continue
	[ -d "$i" ] || continue

	d="${i%/CVS}"

	echo $d
	(cd "$d" && tl $TL cvs -Q -z3 up -P)
done


#!/usr/bin/perl
use warnings;
use strict;

-t && exec "/bin/cat";

undef $/;

my $in = <>;

$in =~ s/^.*\r(?!\n)//gm;

print $in;
Previous: Boaz HarroshNext: Paul Gardiner
Message 5 of 8 in “New to git: sorry for obvious question.”
  1. Paul GardinerFeb 4, 2008
  2. Matthieu MoyFeb 4, 2008
  3. Paul GardinerFeb 4, 2008
  4. Boaz HarroshFeb 4, 2008
  5. Luciano RochaFeb 4, 2008
  6. Paul GardinerFeb 4, 2008
  7. Boaz HarroshFeb 4, 2008
  8. Paul GardinerFeb 4, 2008

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.