How can I pull a remote repository with GitPython?
As the accepted answer says it's possible to use repo.remotes.origin.pull()
, but the drawback is that it hides the real error messages into it's own generic errors. For example when DNS resolution doesn't work, then repo.remotes.origin.pull()
shows the following error message:
git.exc.GitCommandError: 'Error when fetching: fatal: Could not read from remote repository.' returned with exit code 2
On the other hand using git commands with GitPython like repo.git.pull()
shows the real error:
git.exc.GitCommandError: 'git pull' returned with exit code 1stderr: 'ssh: Could not resolve hostname github.com: Name or service not knownfatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.'