Panasonic Youth rob sanheim writes about software, business, ruby, music, stuff and things



Posted
4 April 2008 @ 10pm

Tagged
Git, Rails

Discuss

Zero to a Fully Git Enabled Rails App in the time it takes to drink an espresso

updated: now uses the real Rails git master at github, now that its live.

So you want to set up a fresh Rails app in a fresh git repo, with proper ignores setup, with vendor/rails using a git submodule (which enables switching to any Rails branch or tag locally)? This isn’t rocket science or anything, but I figured I’d post it to see what things could be done better.

Assumptions

  • You have a working, recent version of git installed.
  • You have the git-rails gem installed.
  • You have the bash aliases at the bottom of the post.


rails app_name
cd app_name

git-rails init

gca -m ‘initial commit’

git submodule add git://github.com/rails/rails.git vendor/rails
# bring in rails from github
git submodule init
# Submodule ‘vendor/rails’ (git://github.com/rails/rails.git) registered for path ‘vendor/rails’

git submodule update

gca -m ‘bring in rails via submodule’
# Created commit 3b67dee: bring in rails via submodule
# 2 files changed, 4 insertions(+), 0 deletions(-)
# create mode 100644 .gitmodules
# create mode 160000 vendor/rails

cd vendor/rails
gba # pick branch of Rails you wanna use
git co BRANCH # where BRANCH is the specific branch you want, unless you want the default of going against edge

You’re done!

Here’s those aliases you need:


alias g=’git’
alias gb=’git branch’
alias gba=’git branch -a’
alias gc=’git commit -v’
alias gca=’git commit -v -a’
alias gd=’git diff | mate’
alias gl=’git pull’
alias gp=’git push’


3 Comments

Posted by
Matt Mower
5 April 2008 @ 8am

Hi Rob.

Timely post but it’s not quite working for me. The “git submodule init” and “git submodule update” commands do not seem to do whatever magic is necessary because I can’t see any sign of a .gitmodules file, nor does the commit for bringing in rails go through because there are no changes in the index (and no vendor/rails folder).

I’m using MacOSX 10.5.2 with Git 1.5.4.3 and git-rails 0.2.1.

I’ve never used submodules before so I can’t even begin to guess what I might have gotten wrong. Any ideas?

Regards,

Matt


Posted by
Rob
5 April 2008 @ 11am

Hi Matt

I left out a critical command in the first copy and paste somehow - the actual adding of the rails mirror from sanityinc. I’ve updated the instructions above; the line you need is “git submodule add git://git.sanityinc.com/rails.git vendor/rails” before doing the submodule init and update.


Posted by
Daniel Stockman
8 April 2008 @ 6pm

I love the list of aliases! Biggest (relatively minor) complaint in my quest to grok Git is the lack of SVN-like shortcuts (svn st = status, svn ci = commit, etc).

The (not-so) smart single-quotes, when copied from typographically superior browsers (e.g., Safari), really bugger things up. Here is an attempt at a properly encoded version:


alias g='git'
alias gb='git branch'
alias gba='git branch -a'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gd='git diff | mate'
alias gl='git pull'
alias gp='git push'
alias gs='git status'

SmartyPants, in combination with Markdown, avoids this faux-pas. Both are available as WordPress plugins from http://michelf.com/projects/


Leave a Comment

log_buddy 0.0.2 released If you think Huddle is ripping off Campfire