83 votes

Comment obtenir l'identifiant de commit du responsable du master dans git ?

Je souhaite afficher l'identifiant git commit (c'est-à-dire SHA) du responsable du master sur mon site Web en tant qu'identifiant.

Comment puis-je extraire ces informations de git ?

134voto

Alan Haggai Alavi Points 34260

Cette commande vous donnera le SHA-1 du dernier commit

 git rev-parse HEAD

20voto

Jeet Points 10514

La commande suivante renverra le SHA-1 de HEAD :

 git log -1 --pretty="%H"

3voto

Lars Points 37

Juste un peu moins élégant :

git log | head -1 | sed s/'commit '//

1voto

TaoBeier Points 139

Vous pouvez utiliser:

 git describe --always --dirty


   --dirty[=<mark>], --broken[=<mark>]
       Describe the state of the working tree. When the working tree matches HEAD, the output is the same
       as "git describe HEAD". If the working tree has local modification "-dirty" is appended to it. If a
       repository is corrupt and Git cannot determine if there is local modification, Git will error out,
       unless ‘--broken' is given, which appends the suffix "-broken" instead.

   --all
       Instead of using only the annotated tags, use any ref found in refs/ namespace. This option enables
       matching any known branch, remote-tracking branch, or lightweight tag.

Prograide.com

Prograide est une communauté de développeurs qui cherche à élargir la connaissance de la programmation au-delà de l'anglais.
Pour cela nous avons les plus grands doutes résolus en français et vous pouvez aussi poser vos propres questions ou résoudre celles des autres.

Powered by:

X