git-hash

Get the current git hash in a Python script

◇◆丶佛笑我妖孽 提交于 2019-11-27 05:05:19
问题 I would like to include the current git hash in the output of a Python script (as a the version number of the code that generated that output). How can I access the current git hash in my Python script? 回答1: The git describe command is a good way of creating a human-presentable "version number" of the code. From the examples in the documentation: With something like git.git current tree, I get: [torvalds@g5 git]$ git describe parent v1.0.4-14-g2414721 i.e. the current head of my "parent"