diff --git a/content/cheat sheets/git-fr.md b/content/cheat sheets/git-fr.md index 4391f4b..0a36b50 100644 --- a/content/cheat sheets/git-fr.md +++ b/content/cheat sheets/git-fr.md @@ -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 ``` +**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 ''" 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 : diff --git a/content/cheat sheets/git.md b/content/cheat sheets/git.md index cb443d6..8f90002 100644 --- a/content/cheat sheets/git.md +++ b/content/cheat sheets/git.md @@ -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 ``` +**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 ''" HEAD +git push --force +``` + Another useful trick is `git commit -v`, it allows reviewing your changes before committing. Use of git commit -v