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

Upgrade to 1.5.0 utility

From
Shawn O. Pearce <spearce@spearce.org>
Date
Mar 14, 2007, 06:16 UTC
Message-ID
<20070314061611.GD20978@spearce.org>

Yesterday on #git DrNick wanted a script to update a pre-1.5.0 Git repository to be like a 1.5.0 (and later) style repository.

This basically means rewriting the remotes into .git/config, setting up wildcard tracking branches under refs/remotes and deleting the old tracking branches from the refs/heads namespace.

Much earlier I had cobbled together a short shell script that does this for a *working directory repository*. Please don't use it on a bare repository, at least not without editing, as it is hardcoding the config options. ;-)

Here it is:

cat <<END_OF_SCRIPT >upgrade.sh #!/bin/sh

## ## Upgrades a pre-1.5.0 repository to a 1.5.0-style layout. ## Use at your own risk. I've used it to upgrade many of ## my own repositories, but I also know what I'm doing. ;-) ##

sh remotes2config.sh; # from git.git/contrib

git config core.bare false git config core.logallrefupdates true

for r in $(git remote)
do
  old="`git config --get-all remote.$r.fetch | sed s,^.*:refs/heads/,,`"
  if [ -z "$old" ]
  then
    echo "No fetch lines for $r."
    continue
  fi
  echo "Converting $r..."
  git config --replace-all remote.$r.fetch +refs/heads/*:refs/remotes/$r/*
  git fetch $r
  for r in $old
  do
    case "$r" in
    *:*) echo "Not deleting $r" ;;
    *) git branch -D $r ;;
    esac
  done
done
END_OF_SCRIPT
-- 
Shawn.
Message 1 of 1 in “Upgrade to 1.5.0 utility”
  1. Shawn O. PearceMar 14, 2007

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.