Skip to content

Instantly share code, notes, and snippets.

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

Summary
	- 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

Filters
	- Applied in order
	- Evaluated with `eval` 
	- Variables are piped from the current commit
		- Exported to the environment, prevents possible conflicts in rewriting commits.
- GIT_COMMIT
		- GIT_AUTHOR
		- GIT_AUTHOR_EMAIL
		- GIT_AUTHOR_DATE
		- GIT_COMMIR_NAME
		- GIT_COMMITTER_EMAIL
		- GIT_COMMITTER_DATE

- The hash is rewritten and noted as such. 

Options
—setup
	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

	—tag-name-filter
	Rewrites tag names

—prune-empty
	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/

-f
Force filter-branch to use an existing temporary directory

—state-branch


<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.