Short primer, importing a SVN repository into a GIT one
I wanted to convert parts of the Botlist project to GIT. Basically, I did just that. I saved the history from the Subversion repository and was able to import that into a new GIT repository. My entry will discuss the steps that I took to make that happen, also I work with several different remote machines so I hacked together a startup script for git-daemon.
Get GIT and install
I am working with an Ubuntu Dapper machine (yes, it is an older distro) and I didn't want to go through the hassle of using a very out of date version of git, so we are going to download the most recent git from kernel.org.
wget http://kernel.org/pub/software/scm/git/git-1.5.3.5.tar.gz
tar -xvf git-1.5.3.5.tar.gz
Pre configure and Installation
Actually, before running configure on the git source; you may need to get two
libraries.
On Ubuntu, I did the following:
Run ./configure
At this point, you can start to build the git source; type ./configure at the command prompt and the subsequent make/install commands. Basically, standard steps for compiling and installing a typical linux source package.
Assuming git was built properly, you should be able to import a subversion
project. I suggest creating a directory and then have git create the .git repository information in that particular folder.
That is all that is needed to create a repository from subversion, notice that the svn (.svn) working directory folder is not included in your git project.
Running the git-daemon at machine startup
Unlike other linux daemons, setting up git-daemon is pretty simple. At least for running the git daemon server under the git protocol. Basically, git-daemon is a server for hosting git repositories and this particular server defaults to running on port 9418. GIT also supports hosting repositories through HTTP.
Run whereis git-daemon to find out where the executable is located. It is up to you how to pass the git-daemon arguments, I used a simple wrapper bash script and launched git from there.
[End of Script]
Change the base-path path according to where you want to store your git repositories. In the script above, gitscm is just a regular directory. The subdirectories (for example, botlist) are actual git repositories (that contain the .git directory). Create a symbolic link in your init.d directory, something along the lines of this:
ln -s /usr/local/bin/git-daemon2 git-daemon2
With ubuntu, you can run update-rc.d to ensure that the git-daemon2 script gets launched at startup:
Run and Test
Now, you can start the git-daemon2 script
Get GIT and install
I am working with an Ubuntu Dapper machine (yes, it is an older distro) and I didn't want to go through the hassle of using a very out of date version of git, so we are going to download the most recent git from kernel.org.
wget http://kernel.org/pub/software/scm/git/git-1.5.3.5.tar.gz
tar -xvf git-1.5.3.5.tar.gz
Pre configure and Installation
Actually, before running configure on the git source; you may need to get two
libraries.
On Ubuntu, I did the following:
- sudo apt-cache search libsvn-core-perl
- sudo apt-get install libsvn-core-perl
- sudo apt-get install libcurl3-dev
Run ./configure
At this point, you can start to build the git source; type ./configure at the command prompt and the subsequent make/install commands. Basically, standard steps for compiling and installing a typical linux source package.
- ./configure
- make
- sudo make install
Assuming git was built properly, you should be able to import a subversion
project. I suggest creating a directory and then have git create the .git repository information in that particular folder.
- sudo mkdir -p /usr/local/var/gitscm/botlist.git
- cd /usr/local/var/gitscm/botlist.git
- sudo git-svn clone http://openbotlist.googlecode.com/svn/trunk/openbotlist/
That is all that is needed to create a repository from subversion, notice that the svn (.svn) working directory folder is not included in your git project.
Running the git-daemon at machine startup
Unlike other linux daemons, setting up git-daemon is pretty simple. At least for running the git daemon server under the git protocol. Basically, git-daemon is a server for hosting git repositories and this particular server defaults to running on port 9418. GIT also supports hosting repositories through HTTP.
Run whereis git-daemon to find out where the executable is located. It is up to you how to pass the git-daemon arguments, I used a simple wrapper bash script and launched git from there.
BASE_PATH=/usr/local/var/gitscm
/usr/local/bin/git-daemon --reuseaddr --verbose --base-path=${BASE_PATH} --export-all -- ${BASE_PATH}
[End of Script]
Change the base-path path according to where you want to store your git repositories. In the script above, gitscm is just a regular directory. The subdirectories (for example, botlist) are actual git repositories (that contain the .git directory). Create a symbolic link in your init.d directory, something along the lines of this:
ln -s /usr/local/bin/git-daemon2 git-daemon2
With ubuntu, you can run update-rc.d to ensure that the git-daemon2 script gets launched at startup:
- sudo update-rc.d git-daemon2 defaults
Run and Test
Now, you can start the git-daemon2 script
- git-daemon2 &
- git ls-remote git://127.0.0.1/botlist.git
- To get the project, cd to some directory
- git clone git://127.0.0.1/botlist.git
Comments