我目前正在尝试使用HTTPS通过GitPython推送到Git。我可以成功地完成这项工作,但是每次获取、推送和拉取操作都会提示我输入用户名和密码。在
我希望我的用户名和密码作为命令行参数输入,因为我的脚本会进行一些git交互。作为一种配置管理方法,这个repo可能会在40多个服务器上,我不想设置所有的SSH密钥,特别是因为它通常是由主机上的一个用户(而不是我自己)使用的。在
有人知道如何从python脚本中获取shell的上下文,以编程方式输入我的用户名和密码(它们已经作为命令行中的变量出现在我的代码中),或者是一种将我的用户名和密码传递给GitPython的方法,这样就不会出现shell提示了吗?在
git_repo = Repo.init(repo_dir)
origin = git_repo.remote('origin')
origin.fetch() # Shell prompted here for username and password
git_repo.heads.dev.checkout()
origin.pull() # Shell prompted here for username and password
git_repo.git.add([added_filename])
git_repo.git.commit(commit_message)
origin.push() # Shell prompted here for username and password
目前没有回答
相关问题 更多 >
编程相关推荐