Skip to content
A tool to report status of several git repositories at once.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
janitor.js
janitor.png
janitor.sh
package-lock.json
package.json

README.md

Janitor

Sample output

Janitor is a tool to report status of several git repositories at once. For each repository, it reports working directory status as well as the situation of each local branch.

I made this because I had dozens of folders in a hard drive which was about to be formatted and I wanted to know if there were any changes in my projects that were not uploaded to the could yet.

How to install

Janitor needs Node.js v7.6 or higher to run. To install Node.js, either refer to the official docs or, even better, use nvm by following the steps here.

To install Janitor:

git clone git@github.com:luciopaiva/janitor.git
cd janitor
npm install

How to run

node janitor <PATH_TO_FOLDER_WITH_GIT_REPOSITORIES> [--no-color] [--only-dirty]

Optional parameters:

  • --no-color: should be disabled by default if the output doesn't support it, but feel free to turn it off manually by passing this
  • --only-dirty: omit folders that are git repositories and have no pending changes or commits

Given the following folder structure as an example:

/home/user/projects
  |-> /foo
  |-> /bar
  |-> /foobar
  |-> /barfoo

Here's Janitor's output:

$ node janitor /home/user/projects
Subdirectories found: 4

/foo: git repository
  status: clean
  + master: nothing to push

/bar: unversioned

/foobar: git repository
  status: 2 files changed or added
  + master: nothing to push
  + other-branch: local only

/barfoo: git repository
  status: clean
  + master: must push

Repositories in need of attention: 3

For each folder, Janitor checks if it is a git repository or not. For folders with no repository, "unversioned" will be printed. For git repositories, the line "status" reports current working directory status. It can be either "clean" or tell how many files are modified and need to be committed (and will also warn about eventual conflicts).

Following that comes a list of local branches and their statuses. Branches can be marked as

  • nothing to push: no need to worry about this branch
  • must push: there are local commits that were not pushed to the remote repository
  • local only: branch only exists locally

Running Janitor from anywhere

I wrote a simple Bash script to let me run Janitor from any folder. To use it, add this link to any of your PATH folders:

cd <SOME_FOLDER_IN_YOUR_PATH_ENV_VAR>
ln -s <PATH_TO_JANITOR>/janitor.sh janitor

And then simply cd to a given folder and run janitor from there.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.