Git - How to find all "unpushed" commits for all projects in a directory?

You can find unpushed commits with git cherry, so you should be able to write a bash script like

#!/bin/bash
for file in `find ./ -type d -maxdepth 3` ; do
    cd $file
    git cherry -v
    cd -
done

which will find 3 layers of subdirectories, but it's probably not very nice to look at.

EDIT

As Evan suggests you can use a subshell to avoid cd-ing back a directory, like so

#!/bin/bash
for file in `find ./ -type d -maxdepth 3` ; do
    (cd $file && git cherry -v)
done

You might want to put a pwd command in here somewhere to see which file/directory you're in...


You could have a look at git submodules but personally I don't find them pleasant to work with.Some time ago I thus created a script to work on a collection of git repos: https://github.com/mnagel/clustergit

clustergit allows you to run git commands on multiple repositories at once. It is especially useful to run git status recursively on one folder. clustergit supports git status, git pull, git push, and more.

enter image description here

Tags:

Git

Bash