Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-slice

Git time travel without cloning history you do not need.

git-slice lets you ask for a repository as it looked at a given date, or extract only the part of its history between two points.

git slice github.com/golang/go @2008-07-01

Give me Go as it existed on 1 July 2008.

git-slice resolves the date to a commit, avoids downloading newer history, minimizes old file-object transfers when possible, and leaves you with a real Git working tree that you can inspect with normal Git commands.

Typical uses include code archaeology, reproducing an old bug, building an untagged historical version, studying how a feature evolved, or preparing a smaller history for git bisect.


Two ways to slice history

Snapshot: from the beginning to a point in time

git slice REPO @END

Example:

git slice github.com/golang/go @2008-07-01

Conceptually:

repository history

start ──────────────── END     newer history
                         │          ✕
                         └─ checked out

The resulting directory contains the files from END and the Git history leading to it.

This is the main use case: you ask for a historical state without first cloning years of later development.

Between: keep only a historical window

git slice REPO FROM TO

Examples:

git slice github.com/golang/go 2008-03-01 2008-07-01
git slice github.com/golang/go HASH1 HASH2
git slice github.com/golang/go 2008-03-01 HASH2
older history       requested window        newer history

     ✕          FROM ─────────────── TO           ✕
                                      │
                                      └─ checked out

The result is still a usable Git repository: TO is checked out on disk and the relevant commit graph is available locally. This is useful when you care about the evolution of the project rather than one final snapshot.

Git history is a graph, not a flat timeline. A FROM..TO range can therefore include merged side branches that are reachable from TO. See Development notes for the implementation details.


Syntax

# Historical snapshot
git slice REPO @END

# A bare selector is also accepted as snapshot syntax
git slice REPO END

# Historical window
git slice REPO FROM TO

FROM and TO are selectors: a way to identify a point in repository history.

They may be:

2008-07-01                  calendar date
2008-07-01T12:30:00Z        ISO timestamp
b78676a...                  commit hash
main / v1.0                 branch or tag when the provider can resolve it
start / root / created      first commit reachable from the selected branch

The @ prefix simply makes snapshot intent explicit.

How dates are resolved

For a date such as:

2008-07-01

git-slice asks for the latest commit on the selected branch at or before 23:59:59 UTC on that day.

Date resolution therefore depends on the branch:

git slice REPO @2008-07-01 --branch master

Without --branch, the provider's default branch is used.

created means the first Git commit reachable from that branch. It does not mean the date on which the repository was created on GitHub or GitLab. Imported repositories can have Git history that predates their hosting account by years. git slice dates shows both pieces of information when the provider exposes them.


Repository forms

All of these are accepted:

github.com/golang/go
https://github.com/golang/go.git
git@github.com:golang/go.git

gitlab.com/group/project

owner/repo
/path/to/local/repo

owner/repo is treated as GitHub shorthand.

Local paths and unknown Git servers use the generic Git backend. They work well with full commit hashes, but a generic Git remote cannot portably answer questions such as “which commit corresponds to this date?” without fetching extra history. GitHub and GitLab have provider-specific API resolvers for that job.


What is created?

By default, git-slice creates a new directory and checks the selected final commit out on a local branch named slice.

For example:

git slice github.com/golang/go @2008-07-01

typically creates:

go-2008-07-01/
├── .git/
├── src/
├── doc/
└── ...

This is not just a downloaded patch or a FETCH_HEAD: the directory contains a normal working tree and Git metadata, so commands such as these work normally on the history that was kept:

git status
git log
git show
git diff

Rather than reproduce every remote branch and tag from the original repository, remember that git-slice focus on selected historical state or window.


Options

Option Meaning
-d, --dir PATH Choose the destination directory
-b, --branch NAME Branch used when resolving dates or start
--local-branch NAME Name of the local branch created at TO (default: slice)
--detach Leave the final commit in detached HEAD state
--dates Print the first and last visible commit dates when finished
--keep-on-error Keep the partially created directory after a failure
-h Show command help
--version Print the installed version

If --dir is omitted, the generated directory name includes the repository name and requested date/range so multiple slices are easy to distinguish:

go-2008-07-01
go-2008-03-01--2008-07-01

Resolution helpers

Resolve a date, ref or keyword to a commit

git slice resolve github.com/golang/go 2008-06-21
git slice resolve github.com/golang/go start

This does not create a working tree. It shows what git-slice would use:

repository: golang/go
provider:   github
branch:     master
input:      2008-06-21
commit:     b78676a49d77...
date:       ...

It is useful when you know a date but want the actual SHA.

Inspect repository dates

git slice dates github.com/golang/go
git slice dates .

For GitHub/GitLab, dates reports the first reachable commit, latest commit, and—when available—the hosting platform's repository creation timestamp.

With . it inspects the current local repository instead:

cd some-slice
git slice dates .

This is a convenient alternative to remembering the Git plumbing needed to find the visible ends of the local history.


Installation

Requires Python 3.10+ and Git.

From a release

Download the .whl file from the GitHub Releases page, then install it with uv:

uv tool install git_slice-0.1.0-py3-none-any.whl

uv tool installs command-line applications into their own isolated Python environment and exposes the resulting executable on your PATH.

From the repository

To install the current source tree directly:

uv tool install .

pipx can be used instead with the same general isolation model:

pipx install .

Once installed, the command is available as:

git-slice ...

and, because Git automatically discovers executables named git-<name> on your PATH, also as:

git slice ...

For the full path from pyproject.toml → wheel → isolated environment → git-slicegit slice, see How git-slice becomes a Git command.


Authentication

Private GitHub or GitLab repositories may require a provider token (GITHUB_TOKEN / GH_TOKEN or GITLAB_TOKEN / GL_TOKEN) in addition to your normal Git credentials.


Portability

git-slice is designed for Windows, Linux and macOS. The release workflow runs the automated test suite on all three platforms before a release is built.

See docs/DEVELOPMENT.md for the testing and release workflow.


Limitations and future work

Current limitations, testing gaps, open design questions and possible improvements are documented in docs/FUTURE.md. For implementation details, packaging, transfer strategies and architecture, see docs/DEVELOPMENT.md.


Resources


License

MIT.

About

Slice a Git repository by date or commit range, with targeted history fetching and normal Git CLI integration.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages