Git Flow Posted on June 7, 2012 Git flow is basically just a shell script that automates some parts of git. But the parts that it automates make it pure bliss to use. From Jeff Kreeftmeijer’s blog post on the subject: I’m astounded that some people never heard of it before, so in this article I’ll try to tell you why it can make you happy and cheerful all day. That post is decent introduction in to how to use git flow. The idea is simple; everything is developed in the develop branch, but you work in smaller sets on features, which get their own branch until they are merged back in to the develop branch. When you’re ready to do a feature freeze and start squashing bugs, you create a release branch, and once the code is ready to go live, changes in that branch get merged with master and back to develop. If something breaks on production, you hotfix it and merge those changes back to develop as well. This graph, taken from this excellent presentation, is a pretty solid summary of the flow: Continue reading →
More Git Magic Posted on June 3, 2012 I recently had a chance to watch Gary Bernhardt’s git workflow video and was blown away by a lot of the aliases he has set up (and by his workflow!). One of the coolest and most useful things he had setup was a log viewer that showed commits, their paths, the author, when it happened, comments and the branch they are attached to. Example: You can see my git-flow (an awesome project on it’s own, blog post forthcoming) workflow in there on the left; see how the repo was branched and merged back in? As I said, crazy useful. Setting this up was pretty simple too. Simply grab Gary’s .gitconfig and .githelpers dot files and toss them in your home path. Or, better yet, just copy everything but the [user] data from the .gitconfig and toss it in yours. Then fire off a `git ra` and marvel are the glory!
Git Info in your Bash Prompt Posted on May 24, 2012 I was hanging out with a very cool fellow developer, and while he was showing me something on his computer, I happened to notice that his shell prompt changed when he entered his git repo. The prompt showed what branch was currently loaded, like so: Pretty boss, right?! He told me it was part of oh-my-zsh and that I needed to install that ASAP. Being a long-time user and fan of bash, and someone who does a fair amount of bash scripting on the shell directly, I was hesitant to switch because it would mean learning a new scripting language. It occurred to me, however, that there was likely a way to get the same thing in bash. A cursory look revealed bash-it, which claimed to be “shameless ripoff of oh-my-zsh.” Perfect! Unfortunately, not so much. Most of the stuff that it offered I didn’t want, and using it would mean more modifications to my dotfiles. But, the git part did work, and it was easy to copy too. Here’s how to add it to your own bash shell. Add this code to your .bash_profile or .bashrc (all these years in Linux and I still don’t know the difference) and you’re set. function parse_git_branch { ref=$(git symbolic-ref HEAD 2> /dev/null) || return echo "("${ref#refs/heads/}")" } Now, in the PS1, add a call to that function, like so. export PS1="\u@\h : \w \$(parse_git_branch) $ " Yours likely looks different than mone, but the important bit is \$(parse_git_branch). If you don’t have a PS1 set, you can copy and paste that one. Now, when you enter a path that is a git repo, it’ll show the branch you’re currently using in the prompt. Sounds quite simple, but it’s really handy, especially if you do your git work on the command line! Continue reading →