svn2git for real men
By kenglish
On the server, set up the remote repositories:
1 2 3 | mkdir project1.git cd project1.git git --bare init |
Here’s a script to do them all in one shot, just modifiy the REPOS variable:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #!/bin/sh REPOS="project1 project2 project3 project4" for repo in $REPOS do repo_dir="$repo.git" mkdir -p $repo_dir echo "Creating git directory $repo_dir" cd $repo_dir git --bare init cd .. done exit |
Now, on the workstation:
1 2 | sudo apt-get install git-core git-svn sudo gem install nirvdrum-svn2git --source http://gems.github.com |
Create the authors.txt in the following format:
1 2 | dburger = David Burger <email@email.com> jdoe = John Doe <jdoe@doe.com> |
For one project, do the following:
1 2 3 4 5 | mkdir project1 cd project1 svn2git https://svn.myserver.org/repos/ses --authors ../authors.txt git remote add origin hailstorm.myserver.org:/home/kenglish/repotest/ses.git git push --all |
The script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #!/bin/sh REPOS="project1 project2 project3 project4" for repo in $REPOS do mkdir $repo cd $repo cmd="svn2git https://svn.myserver.org/repos/$repo --authors ../authors.txt" echo $cmd `$cmd` cmd="git remote add origin hailstorm.myserver.org:/home/kenglish/repotest/$repo.git" echo $cmd `$cmd` cmd="git push --all" echo $cmd `$cmd` cd .. echo "DONE EXPORTING $repo" done exit |
Don’t diss the shell script, I leave in the echoes in case i need to test stuff out…
Note: Another option for the authors file is place it in your home directory .svn2git/authors (e.g. /home/kenglish/.svn2git/authors). Svn2git will automatically detect it and use it.
Any questions? Comments?
git merge stategy for deploy.rb
By kenglish
My problem is that I have multiple git branch of a rails project and in each branch, I want to maintain a different value the branch setting my deploy.rb. For example:
In branch v1.0.0-stable
set :branch, "v1.0.0-stable"
In branch, I want v1.0.1-stable
set :branch, "v1.0.1-stable"
In the master branch, I want no value.
The problem is that I often merge from v1.0.1-stable into the master branch and this overwrites the deploy.rb. This can be frustrating because every time I need to remember to remove that “set :branch” line from the deploy.rb. If I forget and deploy from the master, it will deploy version “v1.0.1-stable” instead of master. This always results in my wondering “Why didn’t the deploy work? Why aren’t my changes on the site?”
The only way that I could find to prevent this is to adding a line my gitattributes file.
In .git/info/attributes, I added:
deploy.rb merge="ours"
Ours is a merge strategy and this tells git always apply
ours
This resolves any number of heads, but the result of the merge is
always the current branch head. It is meant to be used to
supersede old development history of side branches.
Note:
If you Google git merge the first 5 pages of results are the man page for the git-merge command. Why does everyone feel the need to replicate the man page all over the internet. Seriously! If what I needed was in the man page, I wouldn’t be using Google!



May 21st, 2009