git: filter--branch

This commit is contained in:
Fabrice Mouhartem 2019-04-24 20:58:08 +05:30
parent a316ef0d51
commit d023872888
2 changed files with 13 additions and 2 deletions

View File

@ -1,7 +1,7 @@
---
Title: Quelques astuces git
Date: 2019-04-22 17:00
Modified: 2019-04-24 14:27+05:30
Modified: 2019-04-24 20:08+05:30
Author: Fabrice
Category: cheat sheets
Tags: git, termtosvg
@ -44,6 +44,11 @@ Pour ajouter un changement atomique dans un fichier (de manière interactive):
```sh
git add -p <file>
```
**Unsafe:** pour réécrire le passé en supprimant un fichier (par exemple si on a commité un donnée *sensible*):
```sh
git filter-branch --prune-empty --tree-filter "rm -f '<fichier>'" HEAD
git push --force
```
Une autre astuce utile: `git commit -v`, qui permet de réviser nos changements avant de commiter.
Une image vaut mieux que mille mots:

View File

@ -1,7 +1,7 @@
---
Title: Some git tricks
Date: 2019-04-22 17:00
Modified: 2019-04-24 14:27+05:30
Modified: 2019-04-24 20:08+05:30
Author: Fabrice
Category: cheat sheets
Tags: git, termtosvg
@ -42,6 +42,12 @@ To add changes in an atomic fashion on a file (in an interactive way):
git add -p <file>
```
**Unsafe:** to remove a file from the past (for instance when you commit some *sensitive* file):
```sh
git filter-branch --prune-empty --tree-filter "rm -f '<file name>'" HEAD
git push --force
```
Another useful trick is `git commit -v`, it allows reviewing your changes before committing.
<object data="/examples/git-cv.svg" width="100%">Use of git commit -v</object>