Skip to content

Instantly share code, notes, and snippets.

@jpcaruana
Created September 27, 2012 14:43
Show Gist options
  • Save jpcaruana/3794384 to your computer and use it in GitHub Desktop.
Save jpcaruana/3794384 to your computer and use it in GitHub Desktop.
convertir un projet SVN vers git
* dac3ecb [fix] bug
* ddee3c9 VERSION='0.23.0-SNAPSHOT'
* 8b4c9ec VERSION='0.22.6'
| * 6bdfaf5 (tag: 0.22.6) Release 0.22.6
|/
* 0b2b6c1 - injecteur bench : reset compteur par file
* 7e00283 - injecteur bench : stopper les acteurs en fin de cycle
echo "Prérequis : installez https://github.com/nothingmuch/git-svn-abandon/blob/master/git-svn-abandon-msg-filter dans votre PATH"
echo "---------------------- QUESTION : ----------------------"
echo "Racine SVN de tous les projets ? -- de la forme http://<serveur>/"; read racine
echo "---------------------- QUESTION : ----------------------"
echo "Nom du projet (sous SVN) ?"; read projet
lettre=${projet:0:1}
url_svn="${racine}/projects/${lettre}/${projet}"
echo "Checkout depuis ${url_svn} vers `pwd`/${projet} ? (5s pour faire CTRL+C)"
sleep 5
mkdir $projet
cd $projet
git svn init "${url_svn}" -T trunk -b branches -t tags
git config user.name "${projet}"
git config user.email "${projet}@cvf.fr"
echo "checking out..."
git svn fetch
echo "conversion des tags..."
git for-each-ref --format='%(refname)' refs/remotes/tags | cut -d / -f4 |
while read ref; do
git tag "${ref}" -m"conversion tag ${ref} depuis SVN" "refs/remotes/tags/${ref}"
done
echo "conversion des branches..."
git for-each-ref --format='%(refname)' refs/remotes | grep -v tags | grep -v trunk | cut -d / -f3 |
while read ref; do
git co "remotes/${ref}" -b "${ref}"
done
git co master
echo "ménage git-svn..."
# strip git-svn noise, retaining tags
git filter-branch --tag-name-filter cat --msg-filter "git svn-abandon-msg-filter" -- --all
# remove the backup refs
git for-each-ref --format='%(refname)' refs/original/ refs/remotes/ | while read ref; do
git update-ref -d "${ref}"
done
for branch in `git branch -r`; do git branch -rd "${branch}"; done
git config --remove-section svn-remote.svn
rm -rf .git/svn/
rm -rf .git/refs/original/
# ménage en local
git reflog expire --expire=now --all
git gc --aggressive --prune=now
git repack -a -d -l
git fsck --full
git clean -d -x -f
# temps total pour neko : 5 minutes
echo "Conversion locale terminée !"
sleep 1
# REMOTE
echo "---------------------- QUESTION : ----------------------"
echo "URL du repo git ? -- de la forme ${USER}@serveur:${projet}.git"; read remote
git remote add origin "${remote}"
git push -u origin master
git push --all
git push --tags
echo "Repo distant ${remote} mis à jour !"
echo "J'ai terminé mon travail."
* dac3ecb [fix] bug
* ddee3c9 VERSION='0.23.0-SNAPSHOT'
* 8b4c9ec (tag: 0.22.6) VERSION='0.22.6'
* 0b2b6c1 - injecteur bench : reset compteur par file
* 7e00283 - injecteur bench : stopper les acteurs en fin de cycle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment