1

I am currently working on and on off on multiple projects. (~30) Some of them go idle for several months. No matter how hard I tried to be organized, I always end up with multiple subdirectories , containing git repos at different depth levels.

I would like to double-check all my work directories to make sure that I did not leave uncommitted changes or untracked folders by accident.

Is there a tool to do that ?

  • scan subdirectories for git repo.
  • list untracked files
  • list uncommited edits
  • list directories with no git repo. ( if they contain files)
Thilo
  • 257,207
  • 101
  • 511
  • 656
Frederic Bazin
  • 1,530
  • 12
  • 27

1 Answers1

2

There is no tool that will do exactly what you want, but you can mix together some command line utilities to get what you want.

Find All Subdirectories that have .git directory.

find . -name `.git` | xargs dirname

Run git status on each one:

for d in `find . -name .git | xargs dirname `; do pushd $d; git status; popd; done;
merlin2011
  • 71,677
  • 44
  • 195
  • 329
  • thanks for the idea. I am turning it into open source ... https://github.com/cloverise/commitful – Frederic Bazin Apr 27 '14 at 04:24
  • 1
    @lenzai, I'm glad you found it useful. You are of course welcome to use it under Creative Commons, like all other content on StackOverflow. If it solved your specific problem, please mark this answer as the accepted answer. – merlin2011 Apr 27 '14 at 04:34
  • I am leaving open for 1 day. in case someone recommend existing solution. Then mark you answer as accepted and publish project – Frederic Bazin Apr 27 '14 at 04:36
  • @lenzai, Fair enough. :) – merlin2011 Apr 27 '14 at 04:38
  • 1
    You should try... with `commitful |cut -f 1 -d "]" |sort|uniq -c` here is what I get: 1 [ahead of ` 18 [clean 8 [not staged 1 [to be committed 15 [untracked ` Current version is already very useful ! – Frederic Bazin Apr 27 '14 at 04:42
  • 1
    @merlin2011 Think `find -name '.git' -printf "%h\n"` would be better. Also, doing `for something in $(find ...)` will cause issues in a number of cases, see [this](http://stackoverflow.com/a/7039579/3076724) for a better syntax. – Reinstate Monica Please Apr 27 '14 at 04:45
  • Hey @BroSlow, you seem know more than me on bash. Would you contribute to github repo ? https://github.com/cloverise/commitful – Frederic Bazin Apr 28 '14 at 13:30