0

I keep all my git repositories in a single folder, and sometimes I want to get a quick status check on all of them, mostly to make sure I'm not leaving the office without pushing any commits.

I wrote a bash script to do that:

for dir in *; do if [[ -d $dir ]]; then echo "checking " $dir; cd $dir; git status; cd ../; fi; done

Which, not for nothing, revealed that I have a couple of untracked files hanging out in one repository that I hadn't realized were not properly tracked. I'm realizing that for this script to be truly awesome, it should highlight the repositories with unstaged changes or unpushed commits, because right now they don't really stand out.

Here's some sample output:

checking  repository_one
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    imgs/one.jpg
    imgs/two.jpg

nothing added to commit but untracked files present (use "git add" to track)
checking  repostory_three
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   modified_thing.md

no changes added to commit (use "git add" and/or "git commit -a")
checking  repository_four
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
checking  repository_five
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

In my terminal, the untracked files and unstaged changes appear in red, but the rest is grey. I'd also love to highlight "Your branch is ahead of 'origin/master' by 1 commit." so I don't leave without pushing it. Can I do that in the script somewhere? Or in my theme? Anywhere?

Is there a better (or different) way to quickly scan for unstaged changes and branches that are ahead by a commit?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.