简体   繁体   中英

Python GIT CHeckout failed due to: exit code(1)

i have an git repo in gitlab. I tried to checkout the master branch with the following lines.

repo = git.Repo(os.path.dirname(__file__), search_parent_directories=True)
repo.git.checkout("master")
ref_repo_root = os.path.join(WORKING_DIRECTORY, 'ref_decoders')

But i got the following error.

E   git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
E     cmdline: git checkout master
E     stderr: 'error: pathspec 'master' did not match any file(s) known to git.'

What i know repo.git.checkout("HEAD~1") works fine. Where is my issue?

The default branch in gitlab since v14.0 is main and not master . Read here for more info: https://about.gitlab.com/blog/2021/03/10/new-git-default-branch-name/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM