Gabriel Robert
Gabriel Robert

Reputation: 3080

Check if push/commit needed in multiple repositories

I have 140 git repos on my computer and I can work on 10-15 of them per week. Is there a way to know if If forgot to commit/push for one of my projects?

These repositories are all at the same place: "C:/Projects".

The output would be something like

  1. C:/Projects/lib1 -> commit and push needed
  2. C:/Projects/lib6 -> commit and push needed
  3. C:/Projects/lib11 -> commit and push needed

Thank you!

Upvotes: 2

Views: 214

Answers (1)

gahooa
gahooa

Reputation: 137312

A pretty simple python script would do it for you:

import glob
import subprocess
import os
from os.path import dirname


dirs = glob.glob('c:/projects/*/.git')

for dir in dirs:
  dir = dirname(dir)   #strip .git off the end

  os.chdir(dir)

  status = subprocess.check_call(('git', 'status'))

  # Check status, and potentially do this

  subprocess.check_call(('git', 'add', '-A'))
  subprocess.check_call(('git', 'commit', '-m', 'Automatic Commit'))
  subprocess.check_call(('git', 'push', 'origin', 'HEAD'))

That is pretty much it. You would need to get python on your computer and in turn tweak this.

Upvotes: 5

Related Questions