Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

140 lines (99 sloc) 5.576 kb

a few git-based tools

These programs...

  • are independent of each other
  • can be installed simply by copying them somewhere in your $PATH (they do require perl 5.10.0 or later though)
  • respond to '--help', '-h', etc., for quick help (some programs may have additional documentation available as given below).


  • tar-checkout-f: approximates what 'git checkout -f' does in terms of deleting unwanted files, but works on a tar file on STDIN.

  • git ls: List files (matching pathname regex, if supplied) in current, local, or remote branches, or tags, or a selection of them.

  • git dig: dig for files in a repo by size or pathname match. If git-dig can't find a file, it's in an unreachable commit or has been gc-d.

  • git branch-check: checks how in-sync the repo is with all its remotes.

  • git-housekeep: check all "registered" repos on your account for sync status, untracked files, etc., and take some actions if needed.

In detail:

  • tar-checkout-f: approximates what 'git checkout -f' does in terms of deleting unwanted files, but works on a tar file on STDIN. Another way to think of it is that it is kinda like 'rsync --delete'.

    Why is it here? Because although git is not a deployment tool, too many people want to use it as such, and tie themselves in knots trying.

    git archive HEAD | tar-checkout-f --yes-I-know /path/to/deploy/dir

    is much safer/saner. The "--yes-I-know" is to make sure you can't blame me if you accidentally pass in $HOME or something as the path :-)

    If you don't supply the --yes-I-know, it will only print what would be deleted. (If the tar file names don't match the actual file names, you could end up deleting a lot more than you thought it should!)

    Dependencies: the feature bloated GNU tools bash, fgrep, and xargs

  • git-ls: Given a list of regex patterns, git-ls matches these to pathnames (not just the basename of the file) and finds all matching files in the current branch. You can add options to search all local branches, remote branches, and tags. Options can be combined, so '-l -r' checks local and remote branches but not the tags.

    See the inline help for some more info.

  • git-dig: Finds files in your git repository. You can look for large files hiding in your repo, and/or you can look for files based on a partial match of the filename. You can look for them in your local branches, tags, remote branches, the stash, or the reflog. Or all of them. Or any combination of them.

    For instance, git dig --check_stash --check_reflog -- --all will find pretty much any file in your repo except from unreachable commits (i.e., not even in the reflog anymore).

    Even better, git dig --check_stash --check_reflog -- --not --all will find you only those files that are in your stashes or reflog but not in any of your branches or tags.

    See here or in the file doc/git-dig.mkd for more examples.

  • git-branch-check: Checks your working repo's branches and the current "updatedness" of each branch vis-a-vis all remote branches of the same name, as well as all other local branches. It'll show you what branches you have that the remotes don't, and vice versa.

    When matching branches are found, it'll show you if they're out of sync ('git branch -v -v' will only show you for the 'upstream' but you might have other remotes you also push to).

    Finally, it'll show you how far your local branches are from each other (see inline help for more on this).

    This is meant to be interactive, using colors, green for stuff that is extra on the local side, red for the other side. See the end of this document for sample output.

    In addition, it can also fast-forward all your local branches if their upstreams have moved ahead.

  • git-housekeep: register each working clone of yours with git-housekeep, then quickly check for untracked files

sample output


pre { background: #fff !important; }
    foo, gh-pages, q
    foo, gh-pages
    bp-v2.0.3, pu-ssh-plus, rrr, temp-br--data-dumper-problem-demo
    foo, q
    bp-v2.0.3, fedora-temp, temp-br--data-dumper-problem-demo

current branch: pu
checking 6 of 6 local branches
   2        pu...gcode/pu
  16        pu...master
   1   2    pu...q
   4   7    pu...vrs
      17    master...q
      19    master...vrs
   5   7    q...vrs

As you can see, I have 3 remotes. Ignoring the test branches, it tells me I don't send the 'gh-pages' branch to gcode or git95. There are also branches on github and git95 that are not on my local repo (the commits may be there but no local checkout).

I have 2 commits on 'pu' that I am yet to send to gcode, though the others look fine. The relationship between my local branches is also shown (if they're "near" enough). For example, my 'pu' is 16 commits ahead of 'master'.

Jump to Line
Something went wrong with that request. Please try again.