Shawna C. Scott

Learning to hack, one day at a time

Menu Close

Tag: git

Git: Fix that last commit

Ever have that “D’oh!” moment, realizing just after you’ve committed some new change that it needs just one more little tweak? (For instance, leaving in some debugging code. Not that I’ve ever done this.)

Luckily, git’s --amend flag is here for you!

Here’s a post that walks you through using it, and the git documentation on undoing things if you want a more in-depth discussion.

On Tumblr

Tab Completion for Git

My new workflow includes creating a branch with git for every new feature, and adding the Pivotal story ID to the branch name. This gives me branch names that end up looking like this:

add_pulse_inputs_79045950

I don’t know about you, but it only took manually typing out 79045950 once before I started looking for a better way. Luckily, git has auto completion capabilities!

Auto-Completion

If you use the Bash shell, Git comes with a nice auto-completion script you can enable. Download it directly from the Git source code at https://github.com/git/git/blob/master/contrib/completion/git-completion.bash . Copy this file to your home directory, and add this to your .bashrc file:

source ~/git-completion.bash

If you want to set up Git to automatically have Bash shell completion for all users, copy this script to the /opt/local/etc/bash_completion.d directory on Mac systems or to the /etc/bash_completion.d/ directory on Linux systems. This is a directory of scripts that Bash will automatically load to provide shell completions.

Check out Git Basics Tips and Tricks for the full instructions, and make your life easier.

 

On Tumblr: http://junior-dev-lessons.tumblr.com/post/100176396858/tab-completion-for-git