2020-04-28 17:29:52 +02:00
|
|
|
|
---
|
|
|
|
|
title: "Rewrite a git commit history"
|
|
|
|
|
date: 2018-03-05
|
2021-03-11 19:47:26 +01:00
|
|
|
|
description: How to rewrite a git commit history
|
|
|
|
|
tags:
|
|
|
|
|
- git
|
2020-04-28 17:29:52 +02:00
|
|
|
|
---
|
|
|
|
|
|
2021-03-11 19:47:26 +01:00
|
|
|
|
## git filter-branch
|
|
|
|
|
|
2020-04-28 17:29:52 +02:00
|
|
|
|
Here is how to rewrite a git commit history, for example to remove a file :
|
2023-04-23 22:33:49 +02:00
|
|
|
|
```sh
|
2020-04-28 17:29:52 +02:00
|
|
|
|
git filter-branch –index-filter "git rm --cached --ignore-unmatch ${file}" --prune-empty --tag-name-filter cat - -all
|
2023-04-23 22:33:49 +02:00
|
|
|
|
```
|