From:
Posted by in , ,
In these days I’ve heard lot of rumors around . After reading some manual/tutorial/guide I discovered that it can be really useful, especially if you spend lot of time coding off-line (that’s my situation).
This is a really small howto that describes how to work on a project versioned with svn (maybe taken from KDE repository ) using git.
What’re the advantages?
Since Git is a distributed revision control system (while svn is a centralized one) you can perform commits, brances, merges,… on your local working dir without being connected to internet.
Next time you’ll be online, you will be able to “push” your changes back to the central svn server.
Steps to follow:
You’ve to:
- install git and git-svn
- create the working dir:
mkdir strigi
- init your git working dir:
cd strigi && git-svn init https://svn.kde.org/home/kde/trunk/kdesupport/strigi
git-svn init command is followed by the address of the svn repository (in this case we point to strigi’s repository) - Find a commit regarding the project (you can get it from ). Warning: the command git-log will show project’s history starting from this revision.
- Perform the command
git-svn fetch -rREVISION
Where REVISION is the number obtained before. - Update your working dir:
git-svn rebase
Now you’ll be able to work on your project using git as revision control system.
To keep update your working copy just perform:
git-svn rebase
You can commit your changes to the svn server using the command:
git-svn dcommit
In this way each commit made with git will be “transformed” into a svn one.
Solve git-svn rebase problems
While adding new cool features to your program, you may experiment some problem when synchronizing with the main development tree. In fact you have to commit all local modifications (using the git-commit
command) before invoking git-svn rebase
.
Sometimes it isn’t reasonable since your changes are not yet ready to be committed (you haven’t finished/tested/improved your work). But don’t worry, git has a native solution also for this problem, just follow these steps:
- put aside your changes using the command:
git-stash
- update your working copy using:
git-svn rebase
as usual - take back your changes typing:
git-stash apply
- clear “the stash” typing:
git-stash clear
After the first step all your uncommitted changes will disappear from the working copy, so you’ll be able to perform the rebase command without problems.
For further informations read git-stash
man page.
That’s all.
Greetings: I would like to thank Thiago Macieira for his help.