Git Smarter: Retrieve deleted files from history [ git unremove ]

In the course of development, there are times you want to look at or retrieve a file deleted sometime in the past - and you probably don’t know when it was deleted. I’ve written a simple git alias that makes it super easy. So how does this work? If you don’t care, then just copy and paste the config line above - if you want to know what’s going on here, read on. ...

March 25, 2014 · 2 min · 368 words

Better Git: Interact With a Branch, Without Checking it Out.

Tricks for interacting with a branch, without checking it out. Browse a directory (like ls): Syntax: 1 2 git show [ref]:[path] git show master:your/path/ See contents of a file (command as above): Syntax: 1 2 git show [ref]:[filepath] git show master:your/path/file.php Checkout a specific file or directory from a different branch: Syntax: 1 2 git checkout [ref] -- [path] git checkout master -- your/path/file.php Note: There are other ways to do similar tasks such as git ls-tree and they may have more options. However I find these to be more accessible and easy to remember.

April 10, 2013 · 1 min · 95 words

Better Git: git fetch not getting tags

I just ran into a little gotcha with regard how fetch handles tags. When it pulls down commits, you will usually see that it also pulls down tags. I was a little confused today when fetch was refusing to pull a tag that was clearly in the repository (git ls-remote --tags) lets you see tags available on the remote). I kept running the fetch command but the tag wouldn’t get pulled down. The reason has to do with the way fetch works, it only fetches tags that are direct references to a commit that is in a branch being fetched. To get all tags regardless of what commits they reference use the fetch in the following way. ...

February 21, 2013 · 2 min · 223 words

Better Git: How to find out what submodules there are in a different branch

Generally speaking Git is fantastic and easy to use - one of the few pain points is where submodules butt heads with branches. Far from solving all the problems in related to this - I’ve found an easy way to find out what submodules are in a branch, commit, or tag without having to check that reference out. This method also shows you the commits that each submodule is currently pointing to. ...

February 5, 2013 · 1 min · 211 words