mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-01-26 11:33:59 +00:00
22 lines
547 B
Plaintext
22 lines
547 B
Plaintext
---
|
|
syntax: markdown
|
|
tags: [tldr, common]
|
|
source: https://github.com/tldr-pages/tldr.git
|
|
---
|
|
# 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`
|