git命令的包装器
gitcmd的Python项目详细描述
概述
gitcmd是git命令的包装器,它可以在需要用户名和密码的地方与git命令交互。
安装
快捷方式:
pip install gitcmd
用法
clone git respositroy
from gitcmd import GitCmd clone_to = 'mydir' url = "https://github.com/philoprove/gitcmd.git" ge = GitCmd(work_dir=clone_to, url=url)
如果使用ssh进行克隆,可能首先需要配置ssh密钥。
clone gitlab,用户名,密码
from gitcmd import GitCmd import os ge = GitCmd(work_dir="clone_to_where", url="", user="user",pwd="pwd") # work dir should be either empty or not exists ge.clone() # after repository was cloned to local , you can execute other commands ge.checkout() ge.pull() ge.execute("git diff ...")