Skip to content

Instantly share code, notes, and snippets.

@schnell18
Created November 24, 2013 05:52
Show Gist options
  • Save schnell18/7623832 to your computer and use it in GitHub Desktop.
Save schnell18/7623832 to your computer and use it in GitHub Desktop.
Move the remote refs created by the git svn migration tool(git svn clone --no-metadata --authors-file -s) to their local refs
for entry in $(git for-each-ref --format="%(objectname)|%(refname)")
do
oldref=$(echo $entry | cut -d '|' -f 2)
if [[ $oldref =~ 'remotes' ]]; then
sha=$(echo $entry | cut -d '|' -f 1)
if [[ $oldref =~ 'remotes/tags' ]]; then
newref=$(echo $oldref | sed -e 's/remotes\/tags/tags/')
elif [[ $oldref =~ 'remotes' ]]; then
newref=$(echo $oldref | sed -e 's/remotes/heads/')
fi
git update-ref $newref $sha
git update-ref -d $oldref
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment