HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

git filter-branch — Change branch history, like removing files. More information: <https://git-scm.com/docs/git-filter-b

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandbranchremovinghistorylikeclichangegit filter-branch

Problem

How to use the git filter-branch command: Change branch history, like removing files. More information: <https://git-scm.com/docs/git-filter-branch>.

Solution

git filter-branch — Change branch history, like removing files. More information: <https://git-scm.com/docs/git-filter-branch>.

Remove a file from all commits:
git filter-branch --tree-filter 'rm {{[-f|--force]}} {{file}}' HEAD


Update author email:
git filter-branch --env-filter 'GIT_AUTHOR_EMAIL={{new_email}}' HEAD


Delete a folder from history:
git filter-branch --tree-filter 'rm {{[-rf|--recursive --force]}} {{folder}}' HEAD

Code Snippets

Remove a file from all commits

git filter-branch --tree-filter 'rm {{[-f|--force]}} {{file}}' HEAD

Update author email

git filter-branch --env-filter 'GIT_AUTHOR_EMAIL={{new_email}}' HEAD

Delete a folder from history

git filter-branch --tree-filter 'rm {{[-rf|--recursive --force]}} {{folder}}' HEAD

Context

tldr-pages: common/git filter-branch

Revisions (0)

No revisions yet.