Git Joys

Image via Wikipedia

I wrote about things that , now it’s time to provide a counter balance by writing things i enjoy in git. Same disclaimer as last time applies, this is not an objective review, it’s just a comparison of things i like in git over svn.

First thing i started appreciating is not having .svn in each and every directory. Imaging you have only one file/dir in a dir, (assuming bash default tab completion) you hit tab twice and nothing is auto completed because there are two things it can choose from. With git it just works. Another advantage of this is that when grep-ing for stuff you don’t get to deal with results from .svn dirs. As it turns out there is .

Next thing i like is that diff/commit operations are per repository global. I have quite often missed some changes because i wasn’t in the repository root. The same reasoning applies for being able to commit from anywhere in the repository. For example:

redduck666@vm04:~/dev/rd666$ echo >> doc/README.deps
redduck666@vm04:~/dev/rd666$ svn diff
Index: doc/README.deps
===================================================================
--- doc/README.deps     (revision 1263)
+++ doc/README.deps     (working copy)
@@ -9,3 +9,4 @@
  - README.deps.python2.5
  - README.deps.python2.6
  - README.deps.python3.0
+
redduck666@vm04:~/dev/rd666$ cd media
redduck666@vm04:~/dev/rd666/media$ svn diff

As opposed to

redduck666@b00:~/dev/prevoz$ echo >> parser/googletransit/urls.py 
redduck666@b00:~/dev/prevoz$ git diff
diff --git a/parser/googletransit/urls.py b/parser/googletransit/urls.py
index 3932a95..26f131e 100644
--- a/parser/googletransit/urls.py
+++ b/parser/googletransit/urls.py
@@ -16,3 +16,4 @@ if settings.DEBUG:
     urlpatterns += patterns("",
         (r'^smedia/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
         )
+ 
redduck666@b00:~/dev/prevoz$ cd trunk/
redduck666@b00:~/dev/prevoz/trunk$ git diff
diff --git a/parser/googletransit/urls.py b/parser/googletransit/urls.py
index 3932a95..26f131e 100644
--- a/parser/googletransit/urls.py
+++ b/parser/googletransit/urls.py
@@ -16,3 +16,4 @@ if settings.DEBUG:
     urlpatterns += patterns("",
         (r'^smedia/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
         )
+

One thing i’ve grown to love in git is it’s feature to warn me about stuff which is present but not tracked. It has occurred to me many times that i had to make another commit because i forgot to svn add stuff, for example:

redduck666@b00:~/dev/prevoz$ touch a
redduck666@b00:~/dev/prevoz$ git commit -a
# On branch routing
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       a

Ever wanted to commit from a train? Or revert to an older revision? Since git stores entire revision history locally you can do that.

Now let’s have a look at working with branches, how long does it take to diff to branches with svn? With git the operation is near instantaneous since there is no network involved (assuming you are diffing a local branch). And here is a controversial claim to conclude with, svn can’t do branches :) . The only thing it can do is dumb property diff tracking. Suppose some developers work on a major new feature, which is given it’s own branch. When it’s ready the trunk maintainer merges the branch into trunk, great now all the changes are attributed to him/her. Yay!

About almir

Hi I'm Almir Karic, i'm studying IT and programming and this is my personal blog where I share my opinion and tips on all things code and tech. I'm also a keen traveler so you might see the odd travel post or 2!