{"thread":{"id":"7243","subject":"Upgrade to 1.5.0 utility","startedAt":"2007-03-14T06:16:12Z","lastAt":"2007-03-14T06:16:12Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"37055","messageId":"20070314061611.GD20978@spearce.org","threadId":"7243","inReplyTo":null,"subject":"Upgrade to 1.5.0 utility","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-03-14T06:16:12Z","receivedAt":"2007-03-14T06:16:12Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Yesterday on #git DrNick wanted a script to update a pre-1.5.0\nGit repository to be like a 1.5.0 (and later) style repository.\n\nThis basically means rewriting the remotes into .git/config, setting\nup wildcard tracking branches under refs/remotes and deleting the\nold tracking branches from the refs/heads namespace.\n\nMuch earlier I had cobbled together a short shell script that does\nthis for a *working directory repository*.  Please don't use it on\na bare repository, at least not without editing, as it is hardcoding\nthe config options.  ;-)\n\nHere it is:\n\ncat <<END_OF_SCRIPT >upgrade.sh\n#!/bin/sh\n\n##\n## Upgrades a pre-1.5.0 repository to a 1.5.0-style layout.\n## Use at your own risk.  I've used it to upgrade many of\n## my own repositories, but I also know what I'm doing.  ;-)\n##\n\nsh remotes2config.sh; # from git.git/contrib\n\ngit config core.bare false\ngit config core.logallrefupdates true\n\nfor r in $(git remote)\ndo\n  old=\"`git config --get-all remote.$r.fetch | sed s,^.*:refs/heads/,,`\"\n  if [ -z \"$old\" ]\n  then\n    echo \"No fetch lines for $r.\"\n    continue\n  fi\n\n  echo \"Converting $r...\"\n  git config --replace-all remote.$r.fetch +refs/heads/*:refs/remotes/$r/*\n  git fetch $r\n  for r in $old\n  do\n    case \"$r\" in\n    *:*) echo \"Not deleting $r\" ;;\n    *) git branch -D $r ;;\n    esac\n  done\ndone\nEND_OF_SCRIPT\n\n-- \nShawn.\n"}]}