Often a lot of the work I do is on services. This means that, in any given day, I’ll perhaps be working on one or more repos. As is the way of git, I commit often to the local working branch and they push to the master at the end of the day, or whenever I’ve got feature, or patch of fix or whatever that needs to go back upstream. First thing in the morning, I’ll also do a pull for each repo I’m going to work on, including dependent repos.
If you’ve got a lot or repos, this quickly gets tedious to cd into each directory, run git status, then git push or git pull, cd back out, then into the next directory, etc etc.
So, I wrote a wee python script called ‘show_status’
Usage: show_status [options] Show Status is awesome. If you tell it a directory to look in, it'll scan through all the sub dirs looking for a .git directory. When it finds one it'll look to see if there are any changes and let you know. It can also push and pull to/from a remote location (like github.com) (but only if there are no changes.) Contact email@example.com for any support. Options: -h, --help show this help message and exit -d DIRNAME, --dir=DIRNAME The directory to parse sub dirs from -v, --verbose Show the full detail of git status -r REMOTE, --remote=REMOTE Push to the master (remotename:branchname) -p PULL, --pull=PULL Pull from the master (remotename:branchname)
Just running ‘show_status’ will always run a non-verbose check on any sub dirs in your current dir, so:
%> show_status -- Starting git status... Scanning sub directories of /home/sites/ --/home/sites/gitstatus : No Changes --/home/sites/projectone : No Changes --/home/sites/project2 : No Changes Done
You can also pass in a directory that you want to use, this is useful if you wanted to use it in other scripts, or if you’re not in a root directory:
%> show_status -d/home/sites
You can add a pull request, which will pull from a remote master. It’s important to note that it’ll only pull from a remote master if there are no local changes waiting to be committed. This is to force you to manage your merges carefully.
%> show_status -pmikepearce:master
Finally, you can do push requests as well, again, this will only work on repos where there is nothing waiting to be commited:
%> show_status -rmikepearce:master
You can grab the whole thing on github (Git Status), or just clone/fork here: firstname.lastname@example.org:MikePearce/Git-Status.git