首页 > 解决方案 > 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()

标签: pythongitgitpython

解决方案


推荐阅读