Skip to main content

git-relevant-history

Extract software component from git repo into a new repo, taking complete relevant history with it.

Background

When software evolves, it is typical for a stable, established software component to be moved out of a git repository to facilitate more comprehensive reuse. One of the pain points of such a move would be losing git history, breaking the possibility of using git blame or git log to understand what led to the current design.

Historically git filter-branch was used for such extracting, and https://github.com/newren/git-filter-repo is a much faster alternative recommended by git now. Both tools work on a static list of path patterns to preserve, so file renames in the past are usually "cut point."

This tool also starts with "what is subcomponent in the current repo to extract?" but then analyzes the history of renames for any existing file. Such a list is used to create a list of patterns for git filter-repo so that effectively the old repo/component becomes standalone repo with a full history of every file, as long as git --follow catches the rename.

So from the extracted component perspective, the only history "lost" is one that would require manual analysis of commits to find file merging/splitting.

Help

Usage documentation for the tool is available via cmdline:

git-relevant-history --help :

Extract enough git history to facilitate git blame and have each line correctly annotated

Wipe all history that has no connection to the current state of the repository.

The resulting repository is a drop-in replacement for the old directory and has all history needed for typical git history use.

Usage:
  git-relevant-history [options] --source=<source_repo> --subdir=<subdir> --target=<target_repo>

Where git repo at <source_repo> would be processed into <target_repo>, in a way that only files starting with
<subdir> would be preserved.


Options:
  --only-specs         Only print git filter-repo specs file as expected by git filter-repo --paths-from-file
  -h --help            show this help message and exit
  -f --force           remove <target_repo> if exists
  -v --verbose         print status messages

Metadata

Release files for git-relevant-history 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for git-relevant-history 1.0.0
File Size Uploaded
git-relevant-history-1.0.0.tar.gz 8.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for git-relevant-history 1.0.0
File Interpreter ABI Platform
git_relevant_history-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.2 kB

Release files / git-relevant-history-1.0.0.tar.gz

Download URL git-relevant-history-1.0.0.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ae23c8c1d88debbfd31d07b75f7c821a7371d84e10952b31e9855a77bf235a9f
BLAKE2b-256 checksum
How to use checksums
4c754b7c079057c0ee8f9e1924f2c003d647e945af1449a36654587df1096526
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/1.6.0 pkginfo/1.8.2 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

Release files / git_relevant_history-1.0.0-py3-none-any.whl

Download URL git_relevant_history-1.0.0-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9de934373a3d8b0d963f468f8b09ca293574b3022717d84ad16157bb5f2e16da
BLAKE2b-256 checksum
How to use checksums
8df19f389c9c136917f6abb37ccf94cf5f11987885327acb02bba2a4fca17c11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/1.6.0 pkginfo/1.8.2 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page