Check git repo creation with or without tags
Discussion on how to move SPC TCV toolboxes to GIT.
Commands used: (also documented on SPC wiki) when final commands are defined..
Inspired from this git manual and from here and here
# Generate empty Authors table
svn log -q https://spcsvn.epfl.ch/repos/TCV/gdat | \
awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); \
print $2" = "$2" <"$2">"}' | sort -u > authors.txt
# Then fill in the authors table e.g. username = FirstName LastName <name.lastname@bla.com>
# Clone from SVN with separate branches and tags, ignoring matlast
git svn clone --trunk /gdat/trunk --branches /gdat/branches/* --tags=/gdat/tags/* --ignore-refs=.*matlast \
https://spcsvn.epfl.ch/repos/TCV --authors-file=authors.txt gdat
# inspect all the branches (incl remote)
git branch -av
# turn tag branches into real git tags and remove branches (may need to play with cut -f argument)
git for-each-ref --format='%(refname)' refs/remotes/origin/tags/ | cut -d / -f 5 |
while read ref; do
git tag "$ref" "refs/remotes/origin/tags/$ref" && git branch -D -r "origin/tags/$ref";
done
# inspect the result
git tag
# Create local branches from remote branches and delete remote branches
# (may need to play with cut -f argument).
# This is necessary since git-svn stores remote branches in a non-default way
# to keep backwards compatibility with the svn repository (which we don't want).
git for-each-ref --format='%(refname)' refs/remotes/origin/ | cut -d / -f 4 |
while read ref;
do
git branch "$ref" "refs/remotes/origin/$ref" && git branch -D -r "origin/$ref";
done;
# inspect the result
git branch -av
# remove trunk branch (identical to master)
git branch -d trunk
# test pushing to a local git repo
git init --bare ~/test-bare.git
git remote add bare ~/test-bare
git push --all bare
git push --tags bare
#then clone a new repo from bare and inspect the result
cd ..
git clone ~/test-bare test
# Go back to the original repo and inspect its size.
du -d1 -h
# If it is unreasonably large (more than a few 10MB typically means it's too large)
# then clean it using tools like [BFG](https://rtyley.github.io/bfg-repo-cleaner/)
# finally (in original extraction repo)
git remote add origin <remote (gitlab) repository url>
git push --all origin
git push --tags origin