Skip to main content

Manage nested git repositories in Gitlab seemlessly(ish)

Project description

gitconductor

tests Coverage License Ruff Documentation PyPI Python versions

gitconductor is a command-line tool and Python library for managing git operations over nested GitLab groups using the official GitLab Python API. It makes it easier to traverse complex group/sub-group hierarchies, perform recursive git operations, without the need for submodule interdependencies, accessing only the sub-groups/projects for which the user has access.

Documentation.

Features

  • Recursive group traversal — operate on entire GitLab group trees, not just individual projects
  • Git operations across nested groups (clone, pull, status, etc.)
  • Unified CLI and Python API
  • Built on top of the official GitLab Python API
  • Designed for automation, scripting, and bulk maintenance

Installation

pip install gitconductor

Gitlab Access

Access to Gitlab is controlled via Personal Access Tokens. To generate:

  1. Login to Gitlab.
  2. Click to user icon.
  3. Click preferences in the drop down.
  4. Click "Personal access tokens" on the left side bar.
  5. Click the "Add new token" button in the top right.
  6. Select "legacy".
  7. Give it a helpful name.
  8. Set the expiry date - for closed systems the longest permissable time of 1 year is easiest.
  9. Click the tick box for:
    • read_user
    • read_repository
    • read_api
    • write_repository
  10. Click the "Generate token" button below.
  11. Copy the new token (noting it can't be viewed again after).

Configuration

Configuration file

Gitconductor can store settings in a file. By default, this is at "~/.config/gitconductor/gitconductor.toml". The location can be changed via the GITCONDUCTOR_CONFIG environment variable. Alternatively, a path can be passed via the top-level --cfg CLI argument.

Environment Variables

  • GITCONDUCTOR_CONFIG: Gitconductor configuration YAML file location.
  • GITCONDUCTOR_GITLAB_API_KEY: Gitlab Private Access Token.
  • GITCONDUCTOR_GITLAB_URL: Gitlab main URL.

GitLab API Keys

Keys can be set up in two ways:

  1. Via an environment variable: export GITCONDUCTOR_GITLAB_API_KEY=<my-private-key>
  2. Via the "gitconductor.toml" file in the gitconductor_gitlab_api_key variable.

Usage (CLI)

Clone

To clone a Gitlab project at, for example, https://gitlab.com/ejb90-group.

gitconductor clone ejb90-group

Branch

gitconductor branch <name>

Checkout

gitconductor checkout <name>

Pull

...

Visualisation

Tree

To visualise the hierarchy of Groups/Projects as a Run, run:

gitconductor viz tree

Results in:

ejb90-group
└── models
    ├── model-a
    ├── model-b
    ├── model-c
    └── subgroup-1
        ├── model-a
        └── model-b

Table

To visualise the hierarchy of Groups/Projects as a Table, run:

gitconductor viz table

Results in:

┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Name          ┃ Tree                                  ┃ Branch ┃ Path                                  ┃ Remote                                                              ┃
┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ model-a       │ ejb90-group/models/model-a            │ main   │ ejb90-group/models/model-a            │ git@gitlab.com:ejb90-group/models/model-a.git                       │
│ model-b       │ ejb90-group/models/model-b            │ main   │ ejb90-group/models/model-b            │ git@gitlab.com:ejb90-group/models/model-b.git                       │
│ model-c       │ ejb90-group/models/model-c            │ main   │ ejb90-group/models/model-c            │ git@gitlab.com:ejb90-group/models/model-c.git                       │
│ model-a       │ ejb90-group/models/subgroup-1/model-a │ main   │ ejb90-group/models/subgroup-1/model-a │ git@gitlab.com:ejb90-group/models/subgroup-1/subgroup-1-model-a.git │
│ model-b       │ ejb90-group/models/subgroup-1/model-b │ main   │ ejb90-group/models/subgroup-1/model-b │ git@gitlab.com:ejb90-group/models/subgroup-1/subgroup-1-model-b.git │
└───────────────┴───────────────────────────────────────┴────────┴───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────┘

Access

To see who has access to a given hierarchy of Groups/Projects, run:

gitconductor viz access

Results in:

┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┓
┃ Group/Project      ┃ User  ┃ Access Level ┃ Public Email ┃ Expiry ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━┩
│ ejb90-group        │ Ellis │ Owner        │              │        │
│ ejb90-group/models │ mobot │ Reporter     │              │        │
└────────────────────┴───────┴──────────────┴──────────────┴────────┘

Python

Gitconductor can also inspect and maniupulate cloned repositories as Python packages. A repository is treated as a Python package when it contains either pyproject.toml or setup.py. Python commands run recursively from the current Gitconductor group, subgroup, or project, so you can work across a whole clone or narrow the operation by changing into a subgroup directory first.

Generate Requirements

Generate a requirements.txt file containing direct references to each Python package in the repository tree:

gitconductor py-requirements

By default, Gitconductor writes to requirements.txt and will not overwrite an existing file unless --force is passed:

gitconductor py-requirements --force

To choose a different output file:

gitconductor py-requirements --fname model-requirements.txt

A pyproject.toml-style dependences snippet is also possible with the --pyproject argument:

gitconductor py-requirements --pyproject

Install Python Packages

Install every Python package in the current Gitlab Group tree into the active Python environment:

gitconductor py-installer

By default this runs uv pip install <path> for each Python package it finds. To install packages in editable mode:

gitconductor py-installer --editable

You can pass a different package-manager command with --package-manager:

gitconductor py-installer --package-manager "python -m pip"

To install from a specific package index:

gitconductor py-installer --index https://example.com/simple

Usage (Python API)

group = gitlab.GitlabGroup(
    gitlab_url=ctx.obj["url"],
    gitlab_key=ctx.obj["key"],
    name=name,
    root=directory,
)
group.recursive_command("clone")

Development & Contributing

Contributions welcome — feel free to open issues or submit PRs. See CONTRIBUTING.md.

License

MIT License • © 2026

Project details


Download files

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

Source Distribution

gitconductor-0.4.2.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitconductor-0.4.2-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file gitconductor-0.4.2.tar.gz.

File metadata

  • Download URL: gitconductor-0.4.2.tar.gz
  • Upload date:
  • Size: 23.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for gitconductor-0.4.2.tar.gz
Algorithm Hash digest
SHA256 813d5638b3f54573651e3f2b8f395681b12d9b3f83036ddc4d8eefd6c853a24a
MD5 6c35228e8cef95efddaea69a33c1e285
BLAKE2b-256 afea108ecec4c37a598c9de64a5595080c236e937f602e71b8f31a9aaee70658

See more details on using hashes here.

File details

Details for the file gitconductor-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: gitconductor-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for gitconductor-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 88843464a525f0f4cfaa4bb530632aac29631f0c308d1a9d7ee4a31f8efd2d2d
MD5 68409783899cc352f05a1d17f9a336d3
BLAKE2b-256 60fbf39b557d022b8d50c948ad7944c523a5bd5bc18ef6543c8eec3db2a9ac89

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page