List git repositories with unpushed changes
I’m reinstalling my OS. I have thousands of repos on my computer. I have a feeling that I’ve made a few changes in some repos while hacking around that are not committed and/or pushed.
From a bash shell on my Debian PC, what’s the best way to find a list of changes that have not yet been committed/pushed to their remotes, and decide whether or not I want to keep the changes?
One Solution collect form web for “List git repositories with unpushed changes”
I’m assuming finding each repo and running
git status in each repo is sufficient for your needs. In which case the following might be a starting point for you:
find / -name "*.git" -type d -print0 | xargs -0 -L 1 -i% bash -c "cd %/..; pwd; git status -s -uno"
find traverses your filesystem, starting at
/ (you may want to restrict that to perhaps
~), searching for .git diretories. The output (null-delimited to handle funny filenames) is piped to xargs, which
cds to each repo, prints the
pwd, and short-form git-status, without listing untracked files.