python - GitPython 使用电子邮件并传入脚本
问题描述
我必须添加我的用户并将 github 传递到代码中。可能吗?我的意思是我每次运行脚本时都需要登录,但使用用户并通过我在代码中的密码:
代码:
from git import Repo
def add_files():
user = 'martinbouhier'
pass = '123pass'
repo_dir = 'python'
if os.path.exists(repo_dir):
shutil.rmtree(repo_dir)
git_url = 'https://github.com/martinbouhier/python'
Repo.clone_from(git_url, repo_dir)
shutil.copy(file_klip, repo_dir)
os.remove(file_klip)
os.chdir(repo_dir)
repo = Repo()
commit_message = 'Actualizacion'
repo.index.add([file_klip])
repo.index.commit(commit_message)
origin = repo.remote('origin')
origin.push()
解决方案
推荐阅读
- python - 如何在pygame的while循环中减少一个生命?
- laravel - laravel 可以包含来自公共文件的刀片路由吗
- c# - Angular + .NET Core Web API + Cookie 身份验证 + 相同域 = 安全吗?
- node.js - 如何在 Flutter 中使用 Auth0 实现社交身份验证?
- oop - 实现派生类型扩展抽象类型的过程
- python - 有没有办法在读取文件时使用 tqdm 函数来显示 Python 中读取过程的进度?
- python - 使用 open() 函数将大字符串数据保存到文本文件时内存不足
- python - 为什么 GAN 无法从某些分布中生成样本?
- kql - 搜索查询应包含度量警报类型的“AggregatedValue”和“bin(TimeGenerated, [roundTo])”
- java - 如何让客户端和服务器在 Docker 中监听相同的端口