Git: Push it! (real good)
After wrestling with some git-remote-branching-merge-problems… I remembered this song…
If you’re using git, you might add this to your [alias]
section in .gitconfig
.
(notice the up-on-this
alias)
ShortURL on Github
After noticing a few patch requests on Rubyforge.. I decided that I’d put the ShortURL gem up on GitHub as I spend quite a bit of my time there these days. :-)
I’ve also thrown up a few lines of code so that you can get the gist of the gem. ;-)
Boxcar Conductor: Rails deployment made easy
In a previous post, I showed how we’ve been working on an interactive deployment process for Rails applications to reduce the time it takes to deploy to a Boxcar.
We began to move our Boxcar deployment recipes into it’s own Rails plugin and just made it available on GitHub.
Introducing Boxcar Conductor
The Boxcar Conductor plugin aims to automate the entire process for deploying to your Boxcar. We’re down to just a few simple commands to run to get your application up and running. While mileage may vary with other hosting providers, we did want to open up this work to the community and centralize our work with the community of Boxcar customers who have helped us build and test these tools.
Install Boxcar Conductor
If you’re running on Edge Rails… you can take advantage of the new support for installing plugins in git repositories.
$ ./script/plugin install git://github.com/planetargon/boxcar-conductor.git
note: If you’re not using edge rails, you can download a tarball and install the plugin manually.
Installing the plugin will add a custom Capfile
and config/deploy.rb
, which has a few things for you to define based on your Boxcar subscription.
Configure Your Boxcar
Once the plugin is installed, you can run the following task:
$ cap boxcar:config
This will ask you a few questions about your deployment needs.
- Which database server will you be using? (along with db user/pass info)
- How many mongrels should run in your cluster?
After a few quick multiple choice answers, you’re application is ready to be deployed and you can run an Boxcar-specific deployment task.
$ cap deploy
We’ve also created a new public project on Lighthouse so that you can submit tickets and ideas to us. With Boxcar, we’re really aiming to remove as many steps from the deployment process that aren’t necessary.
To follow along, visit the project on lighthouse or GitHub.
If you’re interested in learning more about Rails Boxcar, feel free to drop us a line.
Related Posts
Interviewed by Hanselminutes
Earlier this week, Scott Hanselman from Hanselminutes came down to the Planet Argon studio to interview Andy, Gary, and myself about adoption of Git.
The podcast interview is available online now.
Thanks for stopping by Scott!
update: I’d recommend that you also check out another episode of Hanselminutes when he sat down to speak with David Heinemeier Hansson and Martin Fowler.
git-svn is a gateway drug
As we’re migrating away from Subversion to Git, I’m having to learn a lot about git-svn
. Andy has posted a few articles on this topic, but I wanted to share a quick tip that I find myself forgetting.
Working with Subversion branches
While you’re hopefully already familiar with how great local branches are with Git, you might not know that you can connect local branches to remote branches in your Subversion repository. This allows those of us who are using Git locally to work against Subversion branches.
I’m going to assume the following:
- Your team is using Subversion
- Your team already has a branch that you’re working in
- Your team is following Subversion directory conventions (
branches/
,tags/
, andtrunk/
) - You have Git installed (with SVN extensions)
Checkout the Subversion project with Git
Please visit Andy’s tutorial, Git SVN Workflow, for a more detailed explanation of the following commands.
First, we’ll initialize your new local Git repository with git-svn
.
git svn init -s http://svn.yourdomain.com/repos/project_name
Now, you’ll change directories to your new Git repository.
cd project_name
Let’s fetch all previous revisions into your local repository1.
git svn fetch
Great, once this is done… you’re master (local) branch is linked to trunk/
.
Mapping a local repository to a remote branch
Assuming that your team is working in a Subversion branch on the current iteration of work. Our team has a naming convention for branches for each iteration. For example, if we’re in Iteration 18, we’ll write this as ITER-018 everywhere (Basecamp, Lighthouse, Subversion, etc…). At the start of each iteration, we create a new branch with this naming convention.
For ITER-018
, the Subversion branch would be located at:
- http://svn.yourdomain.com/repos/project_name/branches/ITER-018
If you were to do a git branch -r
, you should see ITER-018
show up in the list. Now, the one thing that wasn’t clear when I first read the git-svn
documentation was that you can’t just checkout that branch with one command. In fact, this has tripped me up a few times.
First, you’ll need to checkout a new local branch. I’ve opted to come up with my own convention for local branches and in this case, I’ll name it iter_018
.
git co -b iter_018
So, now I’m in the iter_018 branch, which is local. I’m currently still mapped to trunk/
, which isn’t what we want. However, all we need to do is reset where Git is currently pointed to. We can run git reset to point this to the ITER-018 branch.
git reset --hard ITER-018
That’s it! Now, the local iter_018
branch will point to branches/ITER-018
in your Subversion repository. This will allow you to work with your existing repository branch and still reap the benefits of local Git repositories.
What about master?
Good question. The git reset
command that you ran will ONLY apply that that individual local branch. So, master is still pointing to trunk/
. This will allow you to have several local branches that map to remote branches.
Next Steps…
If you’re working with Git already.. great!
If you’re working in an environment that using Subversion, git svn
provides you the ability to start exploring Git without making your entire team switchover. Perhaps your a consultant and working for a client that uses Subversion… no problem!
We’re still using Subversion for past client projects and are considering GitHub, which just launched (to the public) today for future projects. A few of us are already using GitHub for open source projects.
Fun.. I just saw the following tweet pass by as I began to wrap up this post.
The Gateway Drug… Git reminds me of Cake
Questions?
I know that I glossed over a few things, so feel free to post questions and/or tips for others who are looking to dabble with Git.
1 You’ll likely have problems if you don’t have a Git authors file specified in your git config.
I am forking Rails
...well, creating a fork on GitHub. ;-)
It appears that Rails is moving from Subversion to Git!
Courtenay posted this a little while ago.
git clone git://github.com/rails/rails.git
Check it out the Ruby on Rails project on GitHub.
Start working on your next patch with git…
git clone git://github.com/rails/rails.git
cd rails
git br -a
git br my_patch
git co my_patch
This is cool news. :-)