Lives in Toronto, Canada and works at Nulogy, an enterprise Rails software company.
Bleargh. Time to finally break out of the shell.
So everybody tells me that Git is cool. I’m used to using Mercurial (which I think is great, by the way) which is also a distributed VCS so I think “how hard can it be?” Silly Kirby, the differences are more than just skin deep!
Git and Hg (Mercurial) have two very different philosophies when it comes to version control and these affect how each of them have implemented core features. Git takes the super-user route and lets you do whatever you want, even if that means you might hurt yourself and hose your repo. While Hg tries to do everything it can to prevent you from modifying your history. This means that a lot of that cool branching stuff that Git does, Hg doesn’t want you to do because it doesn’t want you to make a topic branch that is disposable and deletable since someone may have cloned it from you.
It is worth mentioning that there are a host of optional plugins for Hg that let you do pretty much anything that is possible in Git. But since I’m just learning Git, I’m not going to stick my foot any further down my throat on design philosophies until I’m a little more familiar with it. Which brings me to some things about Hg that i just wish Git had.
The first big differences that I noticed were the lack of auto-complete in Git. For instance, if you have modified lib/project/widget.rb in your Hg repo, you can go hg ci li<tab> and if the above file was the only one that you’d changed, Hg is smart enough to auto-complete the rest of the filename for you. Awesome!
I haven’t yet found anything comparable in Git although i did come across .git-completion.bash which has amazing support for auto-completing Git commands, options, tags and branches. It also lets you add something like $(__git_ps1 "(%s)") to your PS1 which will show you what your current branch is when you’re in a Git repo. For even more info you can add the following lines to your .bashrc as well:
GIT_PS1_SHOWDIRTYSTATE=1 #... untagged(*) and staged(+) changes GIT_PS1_SHOWSTASHSTATE=1 #... if something is stashed($) GIT_PS1_SHOWUNTRACKEDFILES=1 #... untracked files(%)
The next thing that i really, really missed about Hg was the super-short aliases for common commands. Like hg ci for hg commit. Git config to the rescue!
$ git config --global alias.co checkout $ git config --global alias.br branch $ git config --global alias.ci commit $ git config --global alias.st status
That’s it for now. Happy Git-ing
Edit: found another cool one from the great Pro Git Book:
$ git config --global alias.unstage 'reset HEAD --'
Unlike Java, the facilities in Ruby 1.8 (and Rails) for logging exceptions and their associated stack traces are poor. You might think that something like this (from an ActiveRecord::Base object) would work:
begin # code that raises some exception rescue Exception => e self.logger.info e end
begin
# code that raises some exception
rescue Exception => e
self.logger.info e.message
self.logger.info e.backtrace.join("\n")
end
I just had to give some props to fellow Nulogite, Ian Bailey, for his outstanding suggestion on what I should call this blog. It's a little ostentatious for me, but he likes "Kirby Superstar" and even made an image to go along with it.
I'm pretty sure that that image is based off of the Nintendo 'Kirby' video games. Don't ask me when he got my picture...Here are some concrete examples of how 'and' can be more dangerous than '&&' in Ruby: http://www.themomorohoax.com/2008/12/08/and-vs-amperand-in-ruby
I've been going a bit crazy about blocks, Procs and lambdas lately trying to figure out how to jury-rig Machinist (which is an awesome piece of code, by the way) syntax on top of Factory Girl. Can anyone tell me the difference between lambda's and Procs? I'll give you a hint: a big part is how returns are handled:Firefox 4 is now in beta and is pretty cool. They've stolen the tab layout from Chrome and resizeable text areas from Safari, so i don't have to switch browsers.
Nulogy also has a customer in Australia now. We're going to have to monitor them and tune our pages so they don't suffer from this: http://mike.bailey.net.au/blog/?p=38 I'd also like to recognize fellow Nulogy founder, Jason Yuen, as his wife recently inducted him into the club of Fathers. Congratulations on successfully reproducing! That's it for now,