Basic Usage:
#bash# mkdir -p ~/git/operator;cd ~/git/operator
#bash# git-svn init http://svn.mozilla.org/labs/operator/
#bash# git fetch
#bash# git checkout -b myoperator
The checkout command does a checkout similar to svn checkout and has all the files in the directory. Git always stores the version information and all administrative information in a .git folder.(which is not shown in the ls below, but a ls -a will show it).
[vinu@zod operator]$ ls
buildit.cmd chrome.manifest defaults LICENSE
buildit.sh chrome.manifest.flat install.rdf userscripts
chrome chrome.manifest.jar jedit_operator.js
[vinu@zod operator]$ du -h
11M .
I had missed the repack option while doing the fetch and instead of searching for the right way to repack, I ran gitk the ui for viewing the
git repository history. It asked for an option to compress the repository and after clicking on Yes and quiting the application I was surprised
by the results.
[vinu@zod operator]$ du -h
1.5M .
That is a real difference in size, though this was a small project checkout - but even for larger projects the ratio is quite impressive.
To checkout the source code for git itself using the git protocol, I tried a clone of git itself.
#bash# mkdir ~/git/git-itself;cd ~/git/git-itself
#bash# git clone git://git.kernel.org/pub/scm/git/git.git
Checking a complete project including branches and tags
With versions prior to 1.5.0.x use
#bash# git-svn multi-init -t tags -b branches -T trunk http://svn.osafoundation.org/server/cosmo
With 1.5.2 and greater use the following command. (multi-init does work with the new version and seems to have the same effect) .
#bash# git-svn init -t tags -b branches -T trunk http://svn.osafoundation.org/server/cosmo
Initialized empty Git repository in .git/
Using higher level of URL: http://svn.osafoundation.org/server/cosmo => http://svn.osafoundation.org/server
#bash#
To do the real work, we have to fetch the entire repository information using git-svn fetch. This process will take a lot of time and be prepared to wait. It took about 2-3 hours or more with a decent broadband connection and with the Intel Macbook (with Linux) I have.
#bash# git-svn fetch
.....
A src/main/java/org/osaf/cosmo/dav/report/caldav/AbstractCalendarDataReport.java
A src/main/java/org/osaf/cosmo/dav/....
.................................
The real output is truncated for clarity.
[vinu@zod cosmo]$ du -h
256M .
Run the following command to compress the svn metadata - it will take some time.
[vinu@zod cosmo]$ git-repack -a -d -f --window=100
Generating pack...
Counting objects: 3211
Done counting 45169 objects.
.....
...
Removing unused objects 100%...
Done.
[vinu@zod cosmo]$ du -h
74M .
To start a new feature (a new branch) the following git command is used
git checkout -b carddav
This will create a new branch called carddav and also do a checkout for you. You can start working on this new branch right away. You can view the list of all the branches using
git branch
The output for me was
* carddav
master
To add or commit files the standard commands like add and commit are used. Other commands like git status, git diff are similar to the svn commands.
To pull the changes from trunk use
git-svn rebase
This pulls the latest in trunk to your origin but not to your local directory.
External Links
--
VinubalajiGopal - 11 May 2007