eddorre

Moving from Subversion to Git & GitHub

December 08, 2008 — 0 Comments

Although Git has been making the rounds in social media for a while, it really caught my attention this year at RailsConf with Scott Chacon’s presentation; Getting Git.

After RailsConf and throughout the summer, I was determined to learn more about the fledgling revision control system but something always came up to squash that effort.

Luckily, Planet Argon uses Git exclusively for their version control system and it’s allowed me to learn some of the basics via my favorite learning technique; trial by fire.

In the few weeks that I have been working with Git I’ve been very impressed with how easy it is to get up and running. I’ve been so impressed that I decided to migrate away from Subversion and move to using Git and GitHub for all of my big projects (including this blogging engine).

WARNING: By following these instructions you are taking responsibility for what happens on your system. As with anything, your mileage may vary and I suggest you do a complete backup of your client machine and server machines.

First this is first; install Git. If you’re on a Debian Linux based machine you can install the Git package by running the following commands:

sudo aptitude install git-core git-svn

If you’re on a Mac, I suggest using MacPorts to install the software by running the following commands (after MacPorts has been installed)

sudo port install git-core git-svn

If you’re using a different OS, consult the Git install documentation.

Before I continue further, it’s important to understand my goal. I want to migrate everything from Subversion to Git and then dump Subversion. I do not want to keep Subversion at the end of this process. There are ways to bridge Git to Subversion just in case you can’t completely remove Subversion from your infrastructure but that’s not my intent.

With that in mind, if you have any uncommitted files from your Subversion repository, I suggest finishing up your work and getting all files committed before proceeding otherwise they won’t be available for Git.

First thing you’ll want to do is to identify yourself to Git so that when you make commits, it’ll know who you are. This is done by the following command (this can also be done on a per project basis but I’m doing it globally):

git config --global user.email your_email_here.com

Once that is finished, we’ll use git-svn to “clone” our Subversion repository. Basically, this checks out your entire project into a branch titled git-svn and then creates a new branch called master. Finally it merges git-svn to your master branch.

The command to run this “cloning” process is:

git svn clone path_to_your_subversion_respository_here

You may need to include “/trunk” to the end of your Subversion repository. Also, depending on the size of your project, the cloning process could take a while.

I’m paranoid, so I like to confirm that both the git-svn and the master branches are merged together at the end of the “cloning” process. First, make sure that you are in the master branch by running the following command:

git checkout master

Then merge git-svn into it by running:

git merge git-svn

You should be greeted with a message that reads “Already up to date.” Everything should now be in Git and you could theoretically be able to dump Subversion now. Obviously, a pragmatic approach would be to archive your Subversion repository on a backup device just in case anything bad happens.

I should note that Git is now running on your local machine and you can make commits to your local repository. This is obviously different from the Subversion client-server model and if this makes you uncomfortable you can certainly setup an origin server to push and pull content from. I chose GitHub primarily because it’s easy to use and setup. Once you are signed up with GitHub, create a repository and run the following commands:

cd existing_git_repository
git remote add origin github_repository_address
git push origin master

I should make a footnote here. Since my Subversion repository isn’t available on the Internet, I wasn’t able to use GitHub’s Subversion import feature. Feel free to use that feature if your Subversion repository is available on the Internet. That way you can skip the whole git-svn thing.

At this point, feel free to delete the git-svn branch as it won’t be needed anymore. You can do this by running the following command:

git branch -d branch_name

Now that you have installed Git, what now?

I would suggest reading the article Git for Designers

More resources:

GitCasts
git-scm.com

Blasting off on a Rocket Ship

December 07, 2008 — 2 Comments

It’s often said (and I wish that I could remember the exact quote) that in order to climb a mountain, you have to take 1000 individual steps. Over the past few years, I’ve been trying to climb over a mountain of my own; my attempted transition from working as a sysadmin to working with code as a web developer.

It’s been a long, arduous path with many days and nights sitting in front of my Mac trying to learn the ins and outs of a very fast moving target. There were times that I didn’t think that I would ever achieve my goals but there is a light at the end of every tunnel.

6 weeks ago, my hard work and determination finally paid off when I accepted a full time developer position at Planet Argon in the heart of Portland, Oregon.

I still can’t believe that I get to work on a Mac with my preferred web framework and programming language. Of course, these are just tools and even in the wrong environment the best tools won’t help you or make you happy. Luckily for me, the environment couldn’t be better. I work alongside a group of talented and funny individuals that make work seem…well not so much like work. I know, it’s cliche, but it’s true.

iPhone Texting Question

December 07, 2008 — 3 Comments

As of this writing, iPhone users have 4 different texting plans to choose from with AT&T. The first and probably the most nefarious is the “Pay Per Use” plan which will cost you $0.20 per text message. The second is the “200 Text Messages” plan that affords 200 text messages a month for $5. From there you can choose the “1500 Text Messages” plan that will cost you $15 a month and the “Unlimited Text Messages” plan that will cost $20 ($30 for a family talk plan) a month. These costs are in addition to any voice and data plans that have already been chosen.

Now that texting is more popular among US mobile users that phone calls (I’m certain that it’s been more popular in other countries for a while) it’s easy to see that this is a lucrative market for AT&T (and other carriers) to be in. It’s so lucrative that it’s netted carriers a total of 100 billion dollars globally.

Before we answer the question, “Why is texting so expensive?” we have to understand what a text message is. A text message, referred to in tech circles as an SMS message, is a text message that is either 160 7-bit characters, 140 8-bit characters (used for binary messages only) or 70 16-bit characters.

What does all of that mean?

A single text message is tiny, microscopic even, in the day and age of high speed data connections. On a 350GB drive (the standard size of a hard drive on a MacBook Pro), you could store approximately 2,348,810,240 text messages. Here is another example; a Lacuna Coil song (8 MB) is the equivalent of 57,344 text messages. If I were to use SMS to download a song (without a plan) it would cost me $11,469!

If you want a more detailed analysis of text messages costs, I would suggest reading the article The True Price of SMS Messages.

Once it’s broken down it’s easy to understand why users and Congress are asking the same question, “Why the hell is texting so expensive?”

One answer, put simply by the article The Rising Cost of Texting, is because it can be.

Enter the iPhone. With its custom applications and rich UI, many developers are surely thinking of making a replacement for the built in text messaging application; one that bypasses AT&T’s draconian text messaging fees. There is one problem. Right now, official iPhone applications that are created by developers cannot run in the background. Unfortunately, this stipulation cripples a text messaging replacement because unless the app is running, you won’t get notified that you have a message.

During WWDC, Apple created a resolution to this by allowing developers to a unified push notification service. This service will notify users when fresh data is available from an application that is not actively being used. These notifications will come in the form of counter badges, audio cues, and pop-up messages that look similar to text alerts.

With a background processing application, it’s easy to recreate the built in texting application while obviating the text messaging costs.

In October, Apple missed its self-imposed deadline for releasing this update to the iPhone but the update is surely coming and you can bet that developers will attempt to release a text messaging replacement and it would be a killer. Taking a look at the top paid applications on the App Store, most aren’t over $2.99. I could easily see a company releasing a text messaging replacement for $20. This may seem steep compared to the apps that are out there right now, but if you compare costs a $20 one-time fee is easily more affordable than $20 a month forever.

Of course the obvious questions are:

  • Will Apple even allow a text messaging replacement app to be allowed into the App Store?
  • If Apple allows an app, will Apple’s servers start crashing under the load of people moving away from the traditional text messaging applications?

Navigating the Command Line in Terminal.app

December 21, 2008 — 0 Comments

I recently switched back to using Apple’s built in Terminal.app (I was using iTerm previously) program for all of my command line needs. There are tons of keyboard shortcuts when you’re using bash but there are a few that are especially handy to have memorized.

  • CTRL-A: Goes to the beginning of the line
  • CTRL-E: Goes to the end of the line

Sometimes you want to get to the middle of the line instead of heading to the beginning or to the end. These will help:

  • OPTION/ALT-B: Jumps cursor back
  • OPTION/ALT-F: Jumps cursor forward

There is one caveat though. The first time I tried the OPTION key trick, the Terminal would just type in strange characters. In order to get Terminal to recognize the OPTION/ALT key as a command key you have to check the option for “Use option as meta key” in the preferences pane of the Terminal app. Once that is done, the Option key shortcuts will work.

Terminal Preferences

Thanks to Alex (aka @demonbane) for showing me this trick.

There are ton of shortcuts for the bash shell but these are among my favorites/most used.

Displaying Git Branch Name with Bash at Command Line

December 21, 2008 — 1 Comment

When you’re first introduced to Git, you’ll probably just be working in your master branch, but eventually you’ll want to test some experimental feature in your code base without disturbing the master branch. Git makes this a snap to do with the command “git checkout -b branchname”.

If you’re working on a few experimental features at a time, each with their own branch name, it gets a little confusing as to which branch you’re currently working in. Of course, you could just type in the commands “git branch” or “git status” but there is an easier way to keep track of what branch you’re actively working in.

Robby posted an excellent article titled Lighthouse tickets and Git branching that helps him and others at Planet Argon with their workflow during the day. By appending the Git branch name to the end of the command line prompt, he’s able to instantly recognize which branch he’s currently working in.

Unfortunately, he doesn’t tell you how he achieved that feat. After Googling for a bit, I came up with a solution that worked for me. NOTE: Robby is using the z shell (zsh) and I’m using the built in shell with OS X; bash. My solution works with bash and not zsh.

First, I created a .bash_profile file by running the following command from my home directory: “touch .bash_profile”.

Then I modified the contents of the file to include the following:


function parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1="\h:\w \u\$(parse_git_branch)$ "

When I’m in a directory that isn’t source controlled via Git, the command line will appear normal:

skyrocket:~ carlos$

Otherwise, it will display the following:

skyrocket:~/work/eddorreblog carlos(master)$

Although I’m using the notation “hostname:working_directory username” you can modify it to your liking using the Bash Prompt HOWTO.