Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

concurrent, pipelined, platform-agnostic Git utilities for managing a large number of Git repositories

Project description

DOI Build Status Coverage Status Build status pypi versions PyPi Download stats

Git Utilities

Platform-independent (Linux/Mac/Windows) Git utilities, useful for managing large (100+) numbers of Git repos. Speed is an emphasis throughout, with concurrency asyncio and pipelining enabled in much of the program.

This uses command-line git because PyGit also requires command-line Git installed, and we don't need the advanced functionality.

An important feature in

ListAllGithubRepos

is showing which forks of your repos have had changes "ahead of" your code. This shows your code is being improved, even if the forked repo didn't make a pull request. I don't know of any other easy way out there to find this.

Count how many total GitHub stars a GitHub account has:

python GithubStarTotal.py username

That will take a couple seconds even for large numbers of repos.

Also see Git utilities for managing large (100+) numbers of users / teams, particularly for education and institutions.

Install

Install Git in a way accessible from the command line line

  • Mac: brew install git
  • Linux: apt install git
  • Windows: command line Git.
python -m pip install -e .

Usage

I didn't know of any other easy ways to do these Git tasks:

  • gitbranch Tells of any non-master branches under directory ~/code
  • gitemail list all contributor email addresses. Optionally, amend email addresses for prior Git commits

Sync large number of git repos

These assume numerous subdirectories under ~/code or c:\code. They work very quickly for large numbers (100+) repos.

  • gitmodified check if any local repos have pending changes
  • gitcheck check if any remote repos are ahead of local
  • gitpull Git pulls all repos
  • gitfetch Git fetches all repos

You can place an empty file .nogit in a subdirectory to skip it.

[optional] speedup with https pull

For public repos, to make the Git remote checking go at least twice as fast, and significantly reduce the computational burden when SSH is used for git push (as is recommended), consider the "pushInsteadOf" global Git config. To do this, when cloning a public repo (including ones you're a collaborator on), use git clone https://. This global SSH push config one-time does SSH push for HTTPS-cloned repos:

git config --global url."ssh://github.com/".pushInsteadOf https://github.com/

The pattern matching can be made for all sites by omitting github.com from the command above, or you can refine it for each site, or even for specific usernames by editing the command above. For private repos, simply clone with SSH as usual

Preview all changed Jekyll files

This is for a website made using Jekyll:

ActOnChanged -j

Github

Python GitHub API

Most users will need a GitHub API token, as the unauthenticated API access is severly limited.

  1. Generate GitHub API token with ONLY the user:email permission.
  2. Copy that text string to a secure location on your computer.

GitHub user stats

ListAllGithubRepos username OauthKey Gives stats on GitHub repos for a particular user. It requires extra prereqs via:

pip install -e .[github]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
gitutils-1.2.3.tar.gz (16.4 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page