Since the middle of this year I started to work more with GIT, basically to track my personal stuff (like scripts and etc) and found out that GIT is such an amazing tool to control your code.
Besides being very easy to work with it, creating and working with branches and being really fast, it’s a distributed revision control software, letting me doing commits at my laptop while I’m off-line and pulling/pushing changes from others when I want, sweet 🙂
But, at test project that I was working we have Subversion, and not GIT. I didn’t want to change it to GIT because everyone was already used to Subversion, and there was no such great justification to do the change, so I decided to search about something that could help me working with GIT at a Subversion repository, and found the git-svn, a really nice tool that turns working with Subversion + GIT a really easy job 🙂
To play more with it I decided to track my local Autotest repository with it, so I just did:
# git-svn clone svn://test.kernel.org/autotest/trunk
With this I just cloned (did a checkout for Subversion users) the Autotest repository to be able to work on it locally, really easy. Just pay attention that this could take some time, because it’ll checkout every revision, and depending on how much revisions you have it can take a long time to finish.
So, yesterday I just decided to improve how we call the LTP test suite inside Autotest. To do this I just created another branch and turned my local code into it, like:
# git branch
# git branch ltp
# git checkout ltp
Switched to branch "ltp"
After this I just made the modification and did the commit locally, like:
# vim client/tests/ltp/ltp.py
# git commit -a
Now with the patch in my hands I just needed to send it to the Autotest mailing list, so, how could git help me with this? Simple:
# git-format-patch -p --stat --signoff last_commit_before_my_commit
This command just created the patch at a local file, with everything I needed (even with the signoff :). After this I just sent it to the mailing list, with another git command:
# git-send-email --to email@example.com 0001-Add-support-to-run-another-test-script-at-ltp.patch
Very easy 🙂
So, today the patch was accepted and I wanted to get that update from upstream to my local repository, did this with:
# git checkout master
Switched to branch "master"
# git-svn rebase
Now that the patch was accepted and is already at my repository I just wanted to remove the branch I created, and this is also really easy to do:
# git branch -D ltp
Deleted branch ltp.
And that’s everything I needed 🙂
So now I can easily work with any Subversion repository by dealing it with GIT. I know that’s not the best solution, but for sure it can help if you need 🙂