git-river is a tool designed to make it easier to work with large
numbers of GitHub and GitLab projects and "forking" workflow that involve
pulling changes from "upstream" repositories and pushing to "downstream"
repositories.
git-river will manage a "workspace" path you configure, cloning repositories
into that directory with a tree-style structure organised by domain, project
namespace, and project name.
$ tree ~/workspace
~/workspace
├── github.com
│   └── datto
│       └── git-river
└── gitlab.com
    └── datto
        └── git-river
git-river requires Python 3.9 or above.
pip3 install git-river
Run git-river <subcommand>. Git's builtin aliasing also allows you to
run git river instead.
Before you can use git-river you must configure a workspace path by running
git-river init PATH or setting the GIT_RIVER_WORKSPACE environment variable.
This should point to a directory git-river can use to clone git repositories
into.
Several commands will attempt to discover various names, and usually have an option flag to override discovery.
- The "upstream" remote is the first of upstreamororiginthat exists. Override with--upstream.
- The "downstream" remote is the first of downstreamthat exists. Override with--downstream.
- The "mainline" branch is the first of mainormasterthat exists. Override with--mainline.
- 
git river clone URL...clones a repository into the workspace path.
- 
git river configmanages the configuration file.- git river config displayprints the loaded configuration as JSON. Credentials are redacted.
- git river config initcreates an initial config file.
- git river config workspaceprints the workspace path.
 
- 
git river forgemanages repositories listed by GitHub and GitLab.- git river forgeruns the- clone+- archived+- configure+- remotessubcommands.
- git river forge cloneclones repositories.
- git river forge configuresets git config options.
- git river forge fetchfetches each git remote.
- git river forge listdisplays remote repositories that will be cloned.
- git river forge remotessets- upstream+- downstreamor- originremotes.
- git river forge tidydeletes branches merged into the mainline branch.
- git river forge archivedlists archived repositories that exist locally.
 
- 
git riveralso provides some "loose" subcommands that work on the repository in the current directory, mostly matching the features from theforgesubcommand.- git river fetchfetches all git remotes.
- git river mergecreates the merge result of all- feature/*branches.
- git river tidydeletes branches merged into the mainline branch.
- git river restartrebases the current branch from the upstream remotes mainline branch.
 
Configuration is a JSON object read from ~/.config/git-river/config.json. Run
git-river config init to create an example configuration file.
- path- path to a directory to use as the "workspace".
- forges- a map of forges.
Forges have the following options. Only type is required - the default
configuration is to use the main public GitHub or GitLab domain without
authentication.
- type(required) - The type of the instance, either- githubor- gitlab.
- base_url(optional) - Base url of the instance. Should not include a trailing slash.- Default for GitHub instances is https://api.github.com.
- Default for GitLab instances is https://gitlab.com.
 
- Default for GitHub instances is 
- login_or_token(optional, GitHub only) - Authentication token.
- private_token(optional, GitLab only) - Authentication token.
- gitconfig(default:- {}) - A key-value map of git config options to set on repositories.
- groups(default:- []) - Include repositories from specific groups.
- users(default:- []) - Include repositories from specific users.
- self(default:- true) - Automatically include the authenticated user's repositories.
{
  "workspace": "~/Development",
  "forges": {
    "gitlab": {
      "type": "gitlab",
      "base_url": "https://gitlab.com",
      "private_token": "...",
      "groups": [],
      "users": [],
      "self": true,
      "gitconfig": {
        "user.email": "[email protected]"
      }
    },
    "github": {
      "type": "github",
      "login_or_token": "...",
      "groups": [],
      "users": [],
      "gitconfig": {
        "user.email": "[email protected]"
      }
    }
  }
}Poetry is used to develop, build, and package git-river. Poetry's
documentation describes how to install it on your OS. Once you've
installed it, create a virtual environment containing git-river and it's
dependencies with poetry install.
You can then run the local version of the CLI with poetry run git-river.
Code is formatted using black, run with poetry run black git_river.
Types are checked using mypy, run with poetry run mypy git_river.
Tests are written using pytest, run with poetry run pytest.
# Download the project and install dependencies
git clone https://github.com/datto/git-river.git
cd git-river
poetry install
# Use the local version of the CLI
poetry run git-river ...
# Test, lint and format code
poetry run black git_river
poetry run mypy git_river
poetry run pytestLicensed under the Mozilla Public License Version 2.0.
Copyright Datto, Inc.
Authored by Sam Clements.