我使用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()
当我执行脚本时,出现以下错误:
To push the current branch and set the remote as upstream, use
git push --set-upstream origin feature/pythontest
refspec="master:master"
。(当我使用master:origin
时,我的'origin'远程仓库也有了一个名为'origin'的分支,而这个分支被我的本地分支'master'所跟踪) - Tim