Python operation Git

  • When building the Devops platform, a small function is to obtain the list of branches or labels of the warehouse, so I wrote relevant scripts in Python

  • Python installation packageGitPythonalsoimport git

  • Related script

#Warehouse operation object

There may be another command to execute heremkdir /root/.ssh && echo 'StrictHostKeyChecking no' > /root/.ssh/configOtherwise, there will be a known when the warehouse host information is obtained for the first time_ Interactive confirmation of hosts. Here is no interactive confirmation

  • Get branch script
#Get warehouse branch
  • Get tag list
    #Get warehouse tag

This work adoptsCC agreement, reprint must indicate the author and the link to this article

Snowflakes floating