views:

116

answers:

3

I have been searching for a solution to this for a while and have not found quite what I need.

I have several Git Repositories in a folder on my Mac (OSX 10.6) and would like a script or tool that will loop through all the repositories and let me know if any of them needs "commit"-ing.

This is my structure
Sites
  /project1
  /project2
  /project3

I want the tool to do a "git status" in Sites/project1, Sites/project2, Sites/project3 and let me know if Sites/project2 and Sites/project3 have changes or new files and needs to be Staged/committed

The closest script I found that might be hackable is here: http://gist.github.com/371828
but even that script wouldn't run and I get an error:
"syntax error near unexpected token `do"
which might have been written for *nix.

A: 

If you just want the status of files in local repos, something like this: http://gist.github.com/389478 should do the trick. You'll need to modify the pattern in the for loop to pickup whatever directories you want.

jcordasc
I will try this soon, I was getting the same syntax errors when I first tried to run this using the "raw" mode, which might have to do with the line breaks. Once I give this a shot, I will let you know.
eapen
+1  A: 

There's a Python based program, uncommitted that sounds like it would do exactly what you want. There's no git support for it yet (just hg and Subversion), but you may be able to help the author implement git support in his app, or take his ideas as how to implement your stuff (he documents his finding method on the project page I linked to).

RyanWilcox
Thanks, this looks promising.
eapen
Thanks Ryan! I ended up creating a version that has Git support and requested a pull at bitbucket and created my repository on github too - http://github.com/eapen/uncommitted
eapen
+1  A: 

It seems that the question has been answered fine, but I wanted to throw in my two cents after working on the same thing.

I went closer to jcordasc's answer by using a simple bash script. I just did one thing a little different. Looking at the help docs for git you can set the git directory and working directory. This eliminates the need to 'cd' to the directories. Not that it really makes that much difference...

#!/bin/bash

for gitdir in `find ./ -name .git`; 
    do 
        workdir=${gitdir%/*}; 
        echo; 
        echo $workdir; 
        git --git-dir=$gitdir --work-tree=$workdir status; 
    done

Obviously his is more advanced/cleaner for how it shows the status'...

Woody2143
Honestly I would have much rather posted this as a comment to jcordasc's answer but damned if I could see how to accomplish that...
Woody2143
Nice and simple!
eapen