Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
git filter-branch notes

	- Rewrite git revision history
		- Applicable to `rev-list` branches
		- Only rewritepositive refs
		- Recommitted without any changes, unless filter is specified
		- Honors `.git/info/grafts` and refs in `refs/replace/`
		- Original refs written in `refs/original/`
		- An expensive disk writing option

	- Applied in order
	- Evaluated with `eval` 
	- Variables are piped from the current commit
		- Exported to the environment, prevents possible conflicts in rewriting commits.

- The hash is rewritten and noted as such. 

	Not a real filter - applied before the loop - commit-specific variables have not been piped in yet. 

	Only applies to the history that touches the given subdirectory. 

—env-filter <command>
	Only modify the environment variables

—tree-filter <command>
	Rewrite the tree and its contents. 

—index-filter <command>
	Only rewrite the index - does not check out the tree (faster) - frequently used withgit rm —cached —ignore-unmatch …

	—parent-filter <command>
Only rewrite the commit’s parents. 

—msg-filter <command>
	Rewrite the commit message. 

—commit-filter <command>
	Performs the commit instead of git commit-tree

	Rewrites tag names

	Removes empty commits (from revised commits that would leave an empty commit). 	Cannot be used with—commit-filter - instead, use the git_commit_non_empty_tree in a commit filter.

—original <namespace>
	Set the namespace. Defaults to refs/original. 

—d <directory>
	Defaults to .git-rewrite/

Force filter-branch to use an existing temporary directory


<rev-list options>


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.