[英]Can't Access Private Git Repo With Personal Access Token
I've never used a private Git repo until recently.直到最近,我才使用私人 Git 回购协议。 I'm having trouble with gaining access to my private repo from my local machine.我在从本地计算机访问我的私人仓库时遇到问题。 Last month, GitHub updated the way you access private repositories.上个月,GitHub 更新了您访问私有存储库的方式。 Now you can't use your username and password.现在您不能使用您的用户名和密码。 I'm given this message when I try with the personal access token: remote: Repository not found. fatal: repository 'https://github.com/[Org]/[Repo].git/' not found
当我尝试使用个人访问令牌时收到此消息: remote: Repository not found. fatal: repository 'https://github.com/[Org]/[Repo].git/' not found
remote: Repository not found. fatal: repository 'https://github.com/[Org]/[Repo].git/' not found
. remote: Repository not found. fatal: repository 'https://github.com/[Org]/[Repo].git/' not found
。
I've already initialized my local repository.我已经初始化了我的本地存储库。 Now I just need to connect it to my private remote repository.现在我只需要将它连接到我的私有远程存储库。 I'd like to use my personal access token instead of ssh.我想使用我的个人访问令牌而不是 ssh。
Here are the commands I'm using on Windows:以下是我在 Windows 上使用的命令:
git remote add origin https://[UserName]:[Token]@github.com/[Org]/[Repo].git
git add .
git commit -m "Commit" ---> Output: On branch master nothing to commit, working tree clean
git push --set-upstream origin master ---> Output: Gives me the error
I don't think your statement "Last month, GitHub updated the way you access private repositories. Now, instead of using your password, you use a personal access token. " is true at all.我认为您的说法“上个月,GitHub 更新了您访问私有存储库的方式。现在,您使用的不是密码,而是个人访问令牌。”根本不是真的。 You can do that, right.你可以这样做,对吧。
To use the token add your repo url like so:要使用令牌,请像这样添加您的 repo url:
git remote add origin https://[Token]@github.com/[Org]/[Repo].git
So the main takeaway from my issue is to make sure the role you're assigned is allowed to push to the private repository.因此,我的问题的主要收获是确保允许分配给您的角色推送到私有存储库。 My team and I assumed that an admin would be able to push, but that doesn't seem to be the case.我和我的团队都认为管理员可以推送,但事实似乎并非如此。 Also, you can use either of these for your origin:此外,您可以将其中任何一个用于您的来源:
https://[Token]@github.com/[Org]/[Repo].git
or或者
https://[UserName]:[Token]@github.com/[Org]/[Repo].git
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.