Insights on Ruby, Git, jQuery, Cappuccino, WordPress, Debian and OS X. Please subscribe if you find something useful!

git clone & pull without changing directories

Posted: May 19th, 2008 | Author: Jerod | Filed under: Ruby | Tags: , | View Comments

If you’re trying to configure git commands in a directory that isn’t pwd, you’ll have to deal with clone and pull a little differently. Clone works like this:

git clone [source location] [destination location]

An example clone into my application’s vendor directory:

git clone git://github.com/rails/rails.git ~/rails/myapp/vendor/rails

Pull works like this:

git --git-dir=/path/to/destination/.git pull

An example pull in the already initiated local rails repository:

git --git-dir=~/rails/myapp/vendor/rails/.git pull

Using these approaches, you can simplify your capistrano recipes. here is an example snippet:

set :rails_source, "git://github.com/rails/rails.git"
 
desc "git the latest rails"
task :git_rails do
  run "mkdir -p #{shared_path}/vendor"
  result = run_and_return "ls #{shared_path}/vendor"
  if result.match(/rails/)
    run "git --git-dir=#{shared_path}/vendor/rails/.git pull"
  else
    run "git clone #{rails_source} #{shared_path}/vendor/rails"
  end
end

See man git-clone and man git-pull for more details.


Railscasts Contest Winner!(ish)

Posted: May 14th, 2008 | Author: Jerod | Filed under: Meta | Tags: , | View Comments

They say that second place is the first loser, but not in Ryan Bates’ most recent Railscasts Contest where all 10 winners were handsomely (handsome? Stop I’m blushing!) rewarded.

Even my humble 6th place nod was given $25 to Amazon and $50 to the Pragmatic Bookshelf! Yea, yea.

I know what you’re wondering. Which books did I choose? After much internal debate, I decided on Advanced Rails Recipes and The Rails Way.

They should be delivered by Friday!