Use pelican page/static linking
This commit is contained in:
62
content/cheat-sheets/git-fr.md
Normal file
62
content/cheat-sheets/git-fr.md
Normal file
@ -0,0 +1,62 @@
|
||||
---
|
||||
Title: Quelques astuces git
|
||||
Date: 2019-04-22 17:00
|
||||
Modified: 2019-04-24 20:08+05:30
|
||||
Author: Fabrice
|
||||
Category: cheat sheets
|
||||
Tags: git, termtosvg
|
||||
Slug: git-tricks
|
||||
Header_Cover: ../images/covers/water.jpg
|
||||
Summary: Une compilation de commandes git que j’utilise ponctuellement
|
||||
Lang: fr
|
||||
---
|
||||
|
||||
Quelques astuces [git](https://git-scm.com/) que j’utilise de temps en temps que j’oublie tout le temps…
|
||||
|
||||
**Attention:** Je ne suis pas un exemple à suivre comme utilisateur de git, et mes manières sont parfois un peu crues.
|
||||
Récemment, la majorité de mes commits sont dues à [pass]({filename}/software/pass-fr.md), et donc la plupart du temps, je suis en train de réparer mes propres erreurs.
|
||||
|
||||
Remettre la branche master `master` sur la branche distante `origin/master` :
|
||||
```sh
|
||||
git checkout origin/master -B master
|
||||
```
|
||||
|
||||
Aller au commit précédent où on avait checkout (de manière similaire à `cd -`) :
|
||||
```sh
|
||||
git checkout -
|
||||
```
|
||||
|
||||
|
||||
Retrouver les commits disparus, c’est très utile lorsqu’on a envie de `cherry-pick` un commit orphelin qu’on a oublié il y a quelque temps :
|
||||
```sh
|
||||
git log --graph --reflog
|
||||
```
|
||||
Quelques explications s’imposent : `--graph` montre l’arbre des commits, ce qui se montre utile pour révéler les feuilles orphelines, et `--reflog` mets au jour tous nos secrets les plus sordides.
|
||||
|
||||
Vous avez peut-être remarqué que vos répertoires git prennent du volume.
|
||||
Pour corriger ça, on peut manuellement appeler le ramasse-miette de notre dépôt.
|
||||
C’est censé se faire tout seul, mais pas assez souvent selon mes standards.
|
||||
```sh
|
||||
git gc --aggressive
|
||||
```
|
||||
|
||||
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 :
|
||||
|
||||
<object data="/examples/git-cv.svg" width="100%">Utilisation de git commit -v</object>
|
||||
|
||||
Une interface ncurses pour git : [tig](https://jonas.github.io/tig/)
|
||||
```sh
|
||||
tig
|
||||
```
|
||||
|
61
content/cheat-sheets/git.md
Normal file
61
content/cheat-sheets/git.md
Normal file
@ -0,0 +1,61 @@
|
||||
---
|
||||
Title: Some git tricks
|
||||
Date: 2019-04-22 17:00
|
||||
Modified: 2019-04-24 20:08+05:30
|
||||
Author: Fabrice
|
||||
Category: cheat sheets
|
||||
Tags: git, termtosvg
|
||||
Slug: git-tricks
|
||||
Header_Cover: images/covers/water.jpg
|
||||
Summary: A compilation of some `git` tricks I keep forgetting.
|
||||
Lang: en
|
||||
---
|
||||
|
||||
Some [git](https://git-scm.com/) tricks I use from time to time and that I forgot everytime…
|
||||
|
||||
**Disclaimer:** I'm not the perfect git user, and my way of using it is especially crude.
|
||||
Recently, most of my git commits are due to [pass]({filename}/software/pass.md), therefore most of those commands are here to fix my own mistakes.
|
||||
|
||||
Reset `master` to `origin/master`:
|
||||
```sh
|
||||
git checkout origin/master -B master
|
||||
```
|
||||
|
||||
Jump back and forth from a commit to another (same behaviour as :
|
||||
```sh
|
||||
git checkout -
|
||||
```
|
||||
|
||||
Find back lost commits, especially useful when you are doing dirty things and want to `cherry-pick` an orphan commit (for instance):
|
||||
```sh
|
||||
git log --graph --reflog
|
||||
```
|
||||
Some explanations: `--graph` show the commit tree, which is useful to notice the orphan leafs, and `--reflog` shows the world all the dirtiness you've done.
|
||||
|
||||
If you noticed that your folder grows, you can manually cast the garbage collector on it. It should do it automatically, but not often enough according to my standards.
|
||||
```sh
|
||||
git gc --aggressive
|
||||
```
|
||||
|
||||
To add changes in an atomic fashion on a file (in an interactive way):
|
||||
```sh
|
||||
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>
|
||||
|
||||
A ncurse-based interface for git: [tig](https://jonas.github.io/tig/)
|
||||
```sh
|
||||
tig
|
||||
```
|
||||
|
||||
<!-- vim: spl=en
|
||||
-->
|
Reference in New Issue
Block a user