prog:git
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| prog:git [2023/07/28 08:35] – [Cloner et configurer d'un dépôt] : précision sur --global root | prog:git [2025/10/20 15:34] (Version actuelle) – [Génération de la clé] : utilisation de sign only root | ||
|---|---|---|---|
| Ligne 17: | Ligne 17: | ||
| git config --global pager.diff false | git config --global pager.diff false | ||
| git config --global pager.grep false | git config --global pager.grep false | ||
| + | # lfs | ||
| + | git config --global lfs.locksverify true | ||
| </ | </ | ||
| + | |||
| + | [[prive: | ||
| Si le dépôt demande constamment le mot de passe, il faut soit configurer l' | Si le dépôt demande constamment le mot de passe, il faut soit configurer l' | ||
| Ligne 100: | Ligne 104: | ||
| ====Fusionner deux dépôts en un seul==== | ====Fusionner deux dépôts en un seul==== | ||
| - | [[https://blog.rom1v.com/2017/07/fusionner-deux-depots-git/|Fusionner deux dépôts git]] {{ :prog:git:fusionner_deux_depots_git_rom1v_blog_2019-10-22_13_30_34_.html |Archive du 12/07/2017 le 22/10/2019}} | + | Depuis le projet A : |
| + | |||
| + | <code bash> | ||
| + | git remote add -f Bproject path/to/B | ||
| + | git merge -s ours --no-commit --allow-unrelated-histories Bproject/ | ||
| + | rm -Rf path/to/B | ||
| + | git read-tree --prefix=path/ | ||
| + | git commit -m "Merge B project as our subdirectory" | ||
| + | </ | ||
| + | |||
| + | Supprimer le submodule des fichiers '' | ||
| + | |||
| + | <code bash> | ||
| + | git add .gitmodules | ||
| + | git commit -m " | ||
| + | </ | ||
| + | |||
| + | [[https://stackoverflow.com/questions/23327701/git-merge-submodule-into-parent-tree-cleanly-and-preserving-commit-history|Git merge submodule into parent tree cleanly and preserving commit history]] {{ :prog:git:git_merge_submodule_into_parent_tree_cleanly_and_preserving_commit_history_-_stack_overflow_22_09_2023_12_24_09_.html |Archive du 27/04/2014 le 22/09/2023}} | ||
| + | |||
| + | Ou | ||
| <code bash> | <code bash> | ||
| Ligne 118: | Ligne 141: | ||
| git update-ref -d refs/ | git update-ref -d refs/ | ||
| </ | </ | ||
| + | |||
| + | [[https:// | ||
| + | |||
| ====Dupliquer un dépôt==== | ====Dupliquer un dépôt==== | ||
| Ligne 190: | Ligne 216: | ||
| {{: | {{: | ||
| - | ====Gestion des conflits==== | + | ====Gestion des conflits |
| git push --force-with-lease | git push --force-with-lease | ||
| Ligne 406: | Ligne 432: | ||
| [[https:// | [[https:// | ||
| + | |||
| + | =====État du dépôt===== | ||
| + | |||
| + | ====bash==== | ||
| + | |||
| + | * Si des fichiers ont été modifiés | ||
| + | |||
| + | <code bash> | ||
| + | if [[ ! -z "$(git status --porcelain)" | ||
| + | then | ||
| + | echo "Some files has been modified." | ||
| + | exit 1 | ||
| + | fi; | ||
| + | </ | ||
| + | |||
| + | Pour utiliser '' | ||
| + | |||
| + | * Si des fichiers non ignorés ont été ajoutés | ||
| + | |||
| + | <code bash> | ||
| + | if [ -n "$(git ls-files --others --exclude-standard)" | ||
| + | </ | ||
| =====Maintenance===== | =====Maintenance===== | ||
| - | ====Suppression des dangling blobs==== | + | ====Vérifie l' |
| <code bash> | <code bash> | ||
| - | git gc --prune=" | + | git fsck --no-dangling |
| </ | </ | ||
| + | |||
| + | < | ||
| + | $ git fsck --no-dangling | ||
| + | error: corrupt loose object ' | ||
| + | error: unable to unpack contents of .git/ | ||
| + | error: 2a9e451f85ba5e26dbe34d742105e877b0942570: | ||
| + | Checking object directories: | ||
| + | Checking objects: 100% (812/812), done. | ||
| + | missing tree 2a9e451f85ba5e26dbe34d742105e877b0942570 | ||
| + | </ | ||
| + | |||
| + | ====Savoir à quel commit appartient un blob==== | ||
| + | |||
| + | <code bash> | ||
| + | git log --raw --all --find-object=< | ||
| + | </ | ||
| + | |||
| + | et pour un objet LFS | ||
| + | |||
| + | <code bash> | ||
| + | git log -S< | ||
| + | </ | ||
| + | |||
| + | ====Avoir tous les enfants d'un commit==== | ||
| + | |||
| + | <code bash> | ||
| + | find_descendants() { | ||
| + | local sha=$1 | ||
| + | line=$(git rev-list --all --children | grep ^$sha) | ||
| + | |||
| + | if [[ $line == *" "* ]]; then | ||
| + | children=$(echo $line | cut -d' ' -f2-) | ||
| + | for child in $children; do | ||
| + | echo $child | ||
| + | find_descendants $child | ||
| + | done | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | find_descendants $1 | ||
| + | </ | ||
| + | ====Suppression des dangling blobs==== | ||
| Ces commits inachevés sont détectés par la commande | Ces commits inachevés sont détectés par la commande | ||
| <code bash> | <code bash> | ||
| git fsck | git fsck | ||
| + | git reflog expire --expire-unreachable=now --expire=now --all --dry-run | ||
| + | git reflog expire --expire-unreachable=now --expire=now --all | ||
| + | git gc --prune=now | ||
| + | git repack | ||
| </ | </ | ||
| Ligne 422: | Ligne 517: | ||
| <code bash> | <code bash> | ||
| git checkout --orphan master | git checkout --orphan master | ||
| - | git gc --aggressive | + | git gc --prune=all |
| </ | </ | ||
| Ligne 465: | Ligne 560: | ||
| </ | </ | ||
| - | Choisir une clé '' | + | Choisir une clé '' |
| ====Afficher la clé publique et privée==== | ====Afficher la clé publique et privée==== | ||
| Ligne 567: | Ligne 662: | ||
| [[https:// | [[https:// | ||
| + | ====fatal: unable to access ' | ||
| + | |||
| + | L' | ||
| + | |||
| + | ====error: object file .git/ | ||
| + | |||
| + | Pour éviter de devoir tout cloner à nouveau et devoir tout recompiler, il faut tester : | ||
| + | |||
| + | <code bash> | ||
| + | find .git/ | ||
| + | git fetch | ||
| + | </ | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | ====gpg: keydb_search failed: Invalid argument==== | ||
| + | |||
| + | < | ||
| + | gpg: keydb_search failed: Invalid argument | ||
| + | gpg: skipped " | ||
| + | [GNUPG:] INV_SGNR 0 XXXXXXXXXXXXXXXX | ||
| + | [GNUPG:] FAILURE sign XXXXXXXXX | ||
| + | gpg: signing failed: Invalid argument | ||
| + | </ | ||
| + | |||
| + | Supprimer le dossier '' | ||
| =====Windows===== | =====Windows===== | ||
| [[https:// | [[https:// | ||
prog/git.1690526149.txt.gz · Dernière modification : de root
