Tag: git
Converting Assembla SVN repositor to GIT
Converting Assembla SVN repositor to GIT
Move a subversion repository, hosted at Assembla to GIT , For this, we expect that you already have a GIT server and repository setup with permission for you to write to it. there is an error to make sure it is 100% clean)
- first create 4 directories
- /data/code/svndump – to download your subversion repositories into
- /data/code/tmpsvn – to load your temporary subversion repository into after downloading
- /data/code/tmpgit1 – to create a temp git repository from your svn repo
- /data/code/tmpgit2 – to create a bare reformatted git repository from your first git
- first open the project / repo in assembla
- Click Import / Export > Download Dump
- right click on the link and copy link then open command line on a machine with svn and git
- cd /data/code wget -O svndump/myrepo.gz “https://linkcopoiedfromassempla” # download the file with quotes (to escape ampersands
- svnadmin create tmpsvn/myrepo #create an empt repositorycd
- gunzip -c svndump/myrepo.gz | svnadmin load tmpsvn/myrepo
- svn log -q file://data/code/tmpsvn/myrepo | awk -F ‘|’ ‘/^r/ {sub(“^ “, “”, $2); sub(” $”, “”, $2); print $2″ = “$2” <“$2″>”}’ | sort -u > users.txt
- git svn clone file:///data/code/tmpsvn/myrepo/ –no-metadata -A users.txt –stdlayout tmpgit1/myrepo
- cd tmpgit1/myrepo
- touch .gitignore #if I dont have any ignore files
- git svn show-ignore > .gitignore #if I do have ignore files i svn, this will return an error if there are no ignore files
- git add .gitignore
- git commit -m ‘Converting Properties from SVN to GIT’ .gitignore
- cd /data/code
- mkdir tmpgit2/myrepo
- cd tmpgit2/myrepo
- git init –bare
- git symbolic-ref HEAD refs/heads/trunk
- Go back to the tmpgit1 repo and push it to the new bare repo and rename the ‘trunk’ to ‘master’
- cd ../../tmpgit1/myrepo
- git remote add bare /data/code/tmpgit2/myrepo
- git config remote.bare.push ‘refs/remotes/*:refs/heads/*’
- git push bare
- cd /data/code/tmpgit2/myrepo
- git branch -m trunk master
- Clean up branches and tags (thanks to http://john.albin.net/git/convert-subversion-to-git for most of this)
- git for-each-ref –format=’%(refname)’ refs/heads/tags |
cut -d / -f 4 |
while read ref
do
git tag “$ref” “refs/heads/tags/$ref”;
git branch -D “tags/$ref”;
done
Now you have a correctly formatted repo at /data/code/tmpgit2/myrepo you can push it to your final git repository
- git remote add origin <your final git repository url >
- git push origin master
This may take a bit of time depending on how much code you have. But once it is complete you can browse your repository in stash.
Converting a Subversion Repository(hosted on Assembla) to a GIT repository (hosted on dedicated Linux Host)
Converting a Subversion Repository(hosted on Assembla) to a GIT repository (hosted on dedicated Linux Host)
We were tasked by our client to move several subversion repositories, hosted at Assembla, to GIT on dedicated internal Linux server. First step was actually installing the Ubuntu Server on their ESXi4 server.
- I downloaded the ubutu 14.04 LTS iso
- Uploaded it to one of the datastores on the ESXi server
- Created a new VM with 4CPU, 8GB RAM and 100 MB disk space.
- I loaded the ubuntu 14.04 iso into the VM CD and started the VM.
- I installed ubuntu with all of the defaults
Next I installed GIT on the server.
- apt-get install git-core
- apt-get install git-svn
Next I clone the svn directory into git.
- git svn clone <svnurl> –no-metadata -A authors-transform.txt –stdlayout /svn/tempreponame/
Ignore the errors about using –prefix, these just caused me headaches and so by NOT using their recommendations to set prefix=origin/ this will work.
Enter your username and password and each time I get an error which says I need to have ‘usera’ I would add usera to users.txt and run the get svn clone command again
- echo “usera = User A <usera@com.com>” >> users.txt
If you receive the error “Unexpected HTTP status 405 ‘Method Not Allowed’ on ‘/svn/wssus.admindash’” this means that you have some protected directories setup in your Assembla. Open the project within Assembla > Settings > Protected branch and remove the directories and run the git svn clone command again
I dont have any ignore files in svn so i fake one
- cd /svn/tempreponame/
- touch .gitignore
- git add .gitignore
- git commit -m ‘Converting Properties from SVN to GIT’ .gitignore
Move the git repository to a new/bare repo and create a symbolic link for the ‘trunk’ coming from SVN
- cd /git/newreponame
- git init –bar
- git symbolic-ref HEAD regs/heads/trunk
Go back to the temporary git repo and push it to the new bar repo and rename the ‘trunk’ to ‘master’
- cd /svn/tempreponame
- git remote add bare /git/newreponame
- git config remote.bar.push ‘refs/remotes/*:refs/heads/*’
- git push bare
- cd /git/newreponame
- git branch -m trunk master
Clean up branches and tags (thanks to http://john.albin.net/git/convert-subversion-to-git for most of this)
- cd /git/newreponame
git for-each-ref –format=’%(refname)’ refs/heads/tags |
cut -d / -f 4 |
while read ref
do
git tag “$ref” “refs/heads/tags/$ref”;
git branch -D “tags/$ref”;
done
Now you have a new repo at /git/newreponame. check it out to confirm it worked by checking it out and confirming that you have the same log history as your original SVN repo
- cd /tmp/
- git clone /git/newreponame
- find . #this should list all of your files
- cd newreponame
- git log