orgit
is a cli tool for organising and syncing git repositories in a consistent and fast way.
orgit
?orgit
streamlines cloning git repos to a consistent location, and keeping them up-to-date. It's useful for developers who work with a large number of repositories within GitHub or GitLab orgs.
orgit
's goals:
orgit
organises your git repositories in your workspace directory in a tree structure that mirrors the URL structure of the remote git repository. For example, if you have a git repository with the URL https://github.com/my-org/my-repo
, then orgit
will clone it into $ORGIT_WORKSPACE/github.com/my-org/my-repo
.
There are three commands.
orgit get REPO_URL@COMMIT
will clone a repository using the repo's HTTP URL.orgit sync ORG_URL
will recursively clone or pull all repositories using the GitHub or GitLab org, user or group URL.orgit list
will list all git repositories in the workspace.Note that orgit
always uses:
origin
as the default remotehttps
as the git transport. To use SSH instead, override the URL in your .gitconfig
(see example below)Either
go install github.com/mtibben/orgit@latest
.export ORGIT_WORKSPACE=~/Developer/src # Set the orgit workspace. The orgit workspace is a directory that mirrors
# the remote repository URL structure.
orgit get github.com/my-org/my-project # Clone a repo into $ORGIT_WORKSPACE/github.com/my-org/my-project
orgit sync github.com/my-org # Clone all repos from the remote org in parallel
orgit list # List all local repos in the workspace
ORGIT_WORKSPACE
can be set to a directory where you want to store your git repositories. By default it will use ~/orgit
GITLAB_HOSTS
can be set to a comma separated list of custom GitLab hosts$ORGIT_WORKSPACE/.orgitignore
file can be used to ignore certain repos when using orgit sync
. This file uses the same syntax as .gitignore
files and also applies to remote repos.In order to use the orgit sync
command, you'll need to use the GitHub or GitLab API. You can set up authentication for GitHub and GitLab using your .netrc
file.
For example:
machine github.com
login PRIVATE-TOKEN
password <YOUR-GITHUB-PERSONAL-ACCESS-TOKEN>
machine api.github.com
login PRIVATE-TOKEN
password <YOUR-GITHUB-PERSONAL-ACCESS-TOKEN>
machine gitlab.com
login PRIVATE-TOKEN
password <YOUR-GITLAB-PERSONAL-ACCESS-TOKEN>
A useful shell alias for changing directory to a repo using fzf
alias gcd="cd \$(orgit list --full-path | fzf) && pwd"
Using shell autocompletion is useful, install it in your shell with orgit completion
If you wish to use SSH transport instead of HTTPS, you can override the URL in your .gitconfig
file. For example:
[url "[email protected]:"]
insteadOf = https://github.com/
[url "[email protected]:"]
insteadOf = https://gitlab.com/
@latest
= the tag with the highest semver version