Using wildcards with git operations

I’ve been using the awesome ‘git’ source code control system for the past year now. The transition from Subversion to git was prompted mostly by my desire to use the awesome application hosting platform AppHarbor, but I picked up git with ease and haven’t looked back.

One of the things I’ve learned about using git in conjunction with Visual Studio 2010 is that git usually likes to be in control of certain operations. In particular, git likes to be in control of ‘remove’ operations.

Removing a file from git is as simple as running

rm filepath/filename.ext

from the git command line, but when that is a long path and filename, it can get a bit … tedious.

Luckily, there are a few quick tips I can share when using the git commandline:

First, the tab key provides command-line completion, just like in a Linux ‘bash’ prompt.

Second (and perhaps even more awesome) – you can use bash (or even DOS-style) wildcards for the filename!

This means that you can easily use the following syntax:

rm MyApp.Library/Some/Really/Long/Path/MyLongFile*.*

How cool is that!?

Site note: If you’re learning git (or just want a nice desk companion for Git) you can’t go wrong with this book:

Pro Git