git: filter--branch
This commit is contained in:
parent
a316ef0d51
commit
d023872888
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
Title: Quelques astuces git
|
Title: Quelques astuces git
|
||||||
Date: 2019-04-22 17:00
|
Date: 2019-04-22 17:00
|
||||||
Modified: 2019-04-24 14:27+05:30
|
Modified: 2019-04-24 20:08+05:30
|
||||||
Author: Fabrice
|
Author: Fabrice
|
||||||
Category: cheat sheets
|
Category: cheat sheets
|
||||||
Tags: git, termtosvg
|
Tags: git, termtosvg
|
||||||
@ -44,6 +44,11 @@ Pour ajouter un changement atomique dans un fichier (de manière interactive):
|
|||||||
```sh
|
```sh
|
||||||
git add -p <file>
|
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 autre astuce utile : `git commit -v`, qui permet de réviser nos changements avant de commiter.
|
||||||
Une image vaut mieux que mille mots :
|
Une image vaut mieux que mille mots :
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
Title: Some git tricks
|
Title: Some git tricks
|
||||||
Date: 2019-04-22 17:00
|
Date: 2019-04-22 17:00
|
||||||
Modified: 2019-04-24 14:27+05:30
|
Modified: 2019-04-24 20:08+05:30
|
||||||
Author: Fabrice
|
Author: Fabrice
|
||||||
Category: cheat sheets
|
Category: cheat sheets
|
||||||
Tags: git, termtosvg
|
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>
|
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.
|
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>
|
<object data="/examples/git-cv.svg" width="100%">Use of git commit -v</object>
|
||||||
|
Loading…
Reference in New Issue
Block a user