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?
You may like the project multi-git-status from Ferry Boender.
https://github.com/fboender/multi-git-status.
"Show uncommited, untracked and unpushed changes in multiple Git repositories."
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 cd
s to each repo, prints the pwd
, and short-form git-status, without listing untracked files.
The previous answer finds uncommitted, but not unpushed commits.
This will find both:
find / -name "*.git" -type d -print0 | xargs -0 -L 1 -i% bash -c "cd %/..; pwd; git status -s -uno; git cherry -v 2>/dev/null"
git cherry
shows the SHA1 of unpushed changes; -v
adds the commit comment; and error redirection suppresses noisy output for repos that lack an upstream.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With