Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check the status of all git repositories at once?

Introduction

In order to check the status of git repositores, git status could be issued from the root of a repository.

C:\path\to\git_repositories\git_repo_1>git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean

If a directory consists of multiple, e.g. 50 git repositories

C:\path\to\git_repositories>dir

 Directory of C:\path\to\git_repositories

  .ssh
  git_repo_1
  ...
  git_repo_50
   0 File(s)
   51 Dir(s)

Nor

C:\path\to\git_repositories>git status .
fatal: Not a git repository (or any of the parent directories): .git

neither

C:\path\to\git_repositories>git status ./.
fatal: Not a git repository (or any of the parent directories): .git

is able to check the status of all repositories

Question

How to check the status of all git repositories at once?

like image 423
030 Avatar asked Jun 22 '14 15:06

030


People also ask

How do I see all git repositories?

You can find the list of all local git repositories by navigating from “Git > Local Repositories.” Based on the previously configured folder for the local repos, Visual Studio will change the context for the local repositories.

How do you check the status of your current repository?

Use the git status command, to check the current state of the repository.

Which command is used to check the status in git?

The git log command is Git's basic tool for exploring a repository's history. It's what you use when you need to find a specific version of a project or figure out what changes will be introduced by merging in a feature branch.

Which command is used to check the status of your repository?

The git status command only outputs information, it won't modify commits or changes in your local repository.


2 Answers

I went with:

find . -name .git -execdir bash -c 'echo -en "\033[1;31m"repo: "\033[1;34m"; basename "`git rev-parse --show-toplevel`"; git status -s' \;

I think it's nicer because treats directories recursively.

Edited to show the name of the repo in a cleaner way.

like image 180
Fernando Crespo Avatar answered Oct 01 '22 14:10

Fernando Crespo


As of 2.34 the for-each-repo command allows running git commands across a list of repos defined in a multi-valued config.

Example config:

[myRepos]
  repo = /full/path/without/expansion/repo1
  repo = ../can/be/relative/repo2
[alias]
  all = for-each-repo --config=myRepos.repo

Then you can run git all status.

like image 42
Allen Avatar answered Oct 01 '22 15:10

Allen