GitPython:git推集上游

GitPython:git推集上游,python,gitlab,gitpython,Python,Gitlab,Gitpython,我使用GitPython克隆一个主分支并签出一个功能分支,我进行本地更新,提交并返回git。代码片段如下所示 注意:我的分支名称是feature/pythontest def git_clone(): repo = Repo.clone_from(<git-repo>, <local-repo>) repo.git.checkout("-b", "feature/pythontest") # I have d

我使用GitPython克隆一个主分支并签出一个功能分支,我进行本地更新,提交并返回git。代码片段如下所示

注意:我的分支名称是feature/pythontest

def git_clone():
    repo = Repo.clone_from(<git-repo>, <local-repo>)
    repo.git.checkout("-b", "feature/pythontest")
    # I have done with file updates 
    repo.git.add(update=True)
    repo.index.commit("commit")
    origin = repo.remote(name="origin")
    origin.push()
origin.push()

origin.push(refspec=“master:origin”)

master是您当地的分支机构,来源是目标

您可以在fetch定义中找到更多详细信息

To push the current branch and set the remote as upstream, use
git push --set-upstream origin feature/pythontest