Outils pour utilisateurs

Outils du site


informatique:git

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
informatique:git [2021/11/22 06:31] – [Des alias pour gagner du temps] alexisinformatique:git [2024/02/09 05:47] (Version actuelle) alexis
Ligne 25: Ligne 25:
 git config --global commit.template <filename> # Utilisation d'un modèle de message pour la validation git config --global commit.template <filename> # Utilisation d'un modèle de message pour la validation
 git config --global alias.st 'status' # Création d'un alias de la fonction "status" git config --global alias.st 'status' # Création d'un alias de la fonction "status"
 +git config --global push.autoSetupRemote true # Création automatique de la branche distante au moment du partage (commande "push")
 </code> </code>
  
Ligne 57: Ligne 58:
 [commit] [commit]
         template = <filename>         template = <filename>
 +[push]
 +        autoSetupRemote = true
 </code> </code>
 <WRAP alert> <WRAP alert>
Ligne 91: Ligne 94:
         ; Fixup a commit into another         ; Fixup a commit into another
         fixup = !sh -c 'git stash --keep-index && SHA=$(git rev-parse $1) && git commit --fixup $SHA && GIT_SEQUENCE_EDITOR=: git rebase --interactive --autosquash $SHA~ && git stash pop' -         fixup = !sh -c 'git stash --keep-index && SHA=$(git rev-parse $1) && git commit --fixup $SHA && GIT_SEQUENCE_EDITOR=: git rebase --interactive --autosquash $SHA~ && git stash pop' -
-        ; Show file names+        ; Show file names in commits
         list-file = !sh -c 'git diff-tree --no-commit-id --name-only -r ${1:-HEAD}' -         list-file = !sh -c 'git diff-tree --no-commit-id --name-only -r ${1:-HEAD}' -
- ; Show branch ordered by last working time+ ; Show branches ordered by last working time
  last-work = branch --sort='-committerdate' --format='%(color:green)%(committerdate:relative)%(color:reset) %(refname:short)' --color=always  last-work = branch --sort='-committerdate' --format='%(color:green)%(committerdate:relative)%(color:reset) %(refname:short)' --color=always
         ; Retrieve a MR locally (gitlab)         ; Retrieve a MR locally (gitlab)
Ligne 104: Ligne 107:
         pt = !git tag -l | xargs git tag -d && git fetch -t         pt = !git tag -l | xargs git tag -d && git fetch -t
         ; Remove local MRs (gitlab)         ; Remove local MRs (gitlab)
-        rmmr = !git checkout master && git branch --list 'mr/*' --format '%(refname:lstrip=2)' | xargs git branch -D+        rmmr = !git reset --hard && git checkout master && git branch --list 'mr/*' --format '%(refname:lstrip=2)' | xargs git branch -D 
 +        ; Show synchronized branches without remote 
 +        stale-branch = !git fetch --all --prune && git branch --verbose | awk '/\\[gone\\]/ {print $1}'
 </code> </code>
 <WRAP info> <WRAP info>
 La commande '':'', utilisée comme éditeur dans la variable ''GIT_SEQUENCE_EDITOR'', fait partie des commandes incluses dans Bash. Voir [[https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#Bourne-Shell-Builtins|ici]] pour plus d'informations. La commande '':'', utilisée comme éditeur dans la variable ''GIT_SEQUENCE_EDITOR'', fait partie des commandes incluses dans Bash. Voir [[https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#Bourne-Shell-Builtins|ici]] pour plus d'informations.
 </WRAP> </WRAP>
 +<WRAP alert>
 +Attention, la version de //sed// disponible sur MacOS ne supporte pas l'option ''--expression''.
 +Il faut la remplacer par l'option ''-e'', le reste étant conservé à l'identique.
 +</WRAP>
 +
 <tabbox Prompt personnalisé> <tabbox Prompt personnalisé>
 <WRAP todo> <WRAP todo>
Ligne 553: Ligne 563:
 </tabbox> </tabbox>
  
 +===== Variables d'environnement =====
 +  * **GIT_SEQUENCE_EDITOR** : Cette variable surcharge l'éditeur configuré lors de l'édition de la liste d'opérations à effectuer lors d'un //rebase// interractif.
 +  * **GIT_TERMINAL_PROMPT** (([[https://serverfault.com/questions/544156/git-clone-fail-instead-of-prompting-for-credentials|automation - git clone - fail instead of prompting for credentials - Server Fault]])): Si cette variable est initialisée à ''0'', ''git'' n'affichera pas l'invite de commande (par exemple, pour demander les identifiants de connexion HTTP).
 +<code bash>
 +# La commande suivante va s'arrêter en erreur sans proposer l'invite de commande
 +GIT_TERMINAL_PROMPT=0 git clone https://github.com/some/non-existing-repo
 +</code>
  
 ===== Liens utiles ===== ===== Liens utiles =====
Ligne 599: Ligne 616:
   - [[https://dev.to/daolf/git-series-13-understanding-git-for-real-by-exploring-the-git-director--5bd0|Understanding git for real by exploring the .git directory - DEV]]   - [[https://dev.to/daolf/git-series-13-understanding-git-for-real-by-exploring-the-git-director--5bd0|Understanding git for real by exploring the .git directory - DEV]]
   - [[https://www.atlassian.com/blog/git/tear-apart-repository-git-way|How to tear apart a repository: the Git way - Work Life by Atlassian]]   - [[https://www.atlassian.com/blog/git/tear-apart-repository-git-way|How to tear apart a repository: the Git way - Work Life by Atlassian]]
 +  - [[https://blog.plover.com/prog/git/tips-2.html|The Universe of Discourse : Things I wish everyone knew about Git (Part II)]]
 +  - [Et merde, Git!?!](https://ohshitgit.com/fr)
 +
 +
  
 <tabbox Humour> <tabbox Humour>
informatique/git.1637591466.txt.gz · Dernière modification : 2021/11/22 06:31 de alexis