← Winnitude! Search  ·  Reader Mode (1440 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 19 LINKS

How to check whether the username and password can access the git repository · gitpython-developers/GitPython · Discussion #1959

Repository navigation

How to check whether the username and password can access the git repository #1959

Unanswered BrentHuang asked this question in Q&A How to check whether the username and password can access the git repository #1959 BrentHuang Aug 22, 2024 · 4 comments · 1 reply Return to top Discussion options

BrentHuang Aug 22, 2024

f"https://{GIT_USERNAME}:{GIT_PASSWORD}@gitee.com/guang11cheng/all_docs.git"

How to use gitpython to check whether the configured username and password can access the git repository?

I just wanted to test the connectivity.

1 You must be logged in to vote

Replies: 4 comments 1 reply

Comment options

Byron Aug 22, 2024
Maintainer

You can do that with git ls-remote <URL> or the equivalent GitPython command. Probably GitPython isn't necessary for this at all.

1 You must be logged in to vote 0 replies Comment options

BrentHuang Aug 23, 2024
Author


My scenario is like this: when user configures a git repo_url with username and password, clicking on the 'Test' button tests if the git repository exists and if the access permissions are ok. it's the same as a connection test for a database. Note that the repository has not yet been cloned locally. And the user may not have the git command line installed on their computer.

1 You must be logged in to vote 1 reply Comment options

BrentHuang Aug 26, 2024
Author

After I verified it, neither way works.

The first way, I randomly change the username, password and repo_url, all display 'Access granted'
The second way, always returns 403

1 You must be logged in to vote 0 replies Comment options

BrentHuang Aug 26, 2024
Author

origin.ls()
Access denied: 'Remote' object has no attribute 'ls'

1 You must be logged in to vote 0 replies Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment Category Q&A Labels None yet 3 participants Converted from issue

This discussion was converted from issue #1958 on August 22, 2024 17:02.