In these days I’ve heard lot of rumors around Git. 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:
- install git and git-svn
- create the working dir:
- init your git working dir:
cd strigi && git-svn init https://svn.kde.org/home/kde/trunk/kdesupport/strigigit-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 cia version control). Warning: the command git-log will show project’s history starting from this revision.
- Perform the command
git-svn fetch -rREVISIONWhere REVISION is the number obtained before.
- Update your working dir:
git-svn rebaseNow you’ll be able to work on your project using git as revision control system.
To keep update your working copy just perform:
You can commit your changes to the svn server using the command:
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
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:
- update your working copy using:
git-svn rebaseas usual
- take back your changes typing:
- clear “the stash” typing:
git-stash clearAfter 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.
A special mention goes to Thiago Macieira for his help.