Skip to content

Git Trim is a deterministic tool to manipulate trees contained in git commits.

License

Notifications You must be signed in to change notification settings

fardream/gitrim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gitrim

Git Trim is a deterministic tool to manipulate trees contained in git commits, and it is based on the excellent go-git library.

Go Reference

Trim/Filter Git History

Often, the history and files contained in a git repository need to be filtered in some way. One simple case will be a contributor is only allowed to access part of the repo. This can be done through git-filter-branch, although no so user-friendly.

gitrim does just that:

  1. read git commit history.
  2. from start, filter the tree contained in the commit and copy over author, committor, commit message. The parents are replaced with the newly created commits, and GPG signatures are omitted.

As long as the filters don't change, the generated git history is deterministic and can be one-to-one mapped back to the original repo.

Modifications made in the trimmed/filtered repo can be recreated by

  1. filter the changes, and reject any changes that don't pass the filter.
  2. apply them back to the original repo, copying over author, committor, commit message, and add the original commits as parents. GPG signatures are again omitted.

The commits in the filtered/trimmed repo will match the commit reproduced from original repo if they are without GPG signatures.

Filters

The filter all implements the Filter interface

The pattern used is a more restricted version of the pattern used by .gitignore.

  • ** is for multi level directories, and it can only appear once in the match.
  • * is for match one level of names.
  • ! and escapes are unsupported.
  • paths are always relative to the root (the leading / is implicit). For example, LICENSE will only match LICENSE in the root of the repo. To match LICENSE at all directory levels, use **/LICENSE.

Refer to documentation on PatternFilter

DotGit

gitrim, through go-git, operates on the contents of .git (or dotgit) folder (the commit, blob, and tree objects).

Example

See Examples

CLI

  • filter-git-hist filters the history of a git repo and output it to another git repo.
  • expand-git-commit expands the new commit back to the original repo.
  • dump-git-tree prints the files of a branch/tree/commit/head. Optionally filters can be applied.
  • remve-git-gpg removes gpg signatures for commits.

About

Git Trim is a deterministic tool to manipulate trees contained in git commits.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages