简体   繁体   English

无法使用个人访问令牌访问私人 Git 回购

[英]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.

相关问题 Git clone总是要求个人访问令牌(私人仓库) - Git clone always asks for Personal Access Token (private repo) 从私有 Git 存储库安装 Pip,在 Git URL 中使用个人访问令牌 - Pip install from private Git repo, with Personal access token in Git URL 即使我已经给了所有范围,也无法使用个人访问令牌访问git private仓库 - Can't access git private repos using personal access token even though I have given it all the scopes 使用个人访问令牌 Netbeans 克隆私有 Github 回购 - Clone a Private Github Repo with a Personal Access Token Netbeans 使用 TFS 个人访问令牌克隆 Git Repo - Cloning Git Repo using TFS Personal Access Token 个人访问令牌 in.git 配置 - Personal Access Token in .git config Pip 使用 Gitlab-CI 上的个人访问令牌从 Gitlab 安装私有仓库 - Pip install a private repo from Gitlab with Personal Access Token on Gitlab-CI 无法让个人访问令牌与 github 一起用于自己的回购 - Can't get personal access tokens to work with github for own repo 如何使用个人访问令牌在 github 操作工作流 (B) 中从不同的存储库 (B) 提交和推送到私有存储库 (A) - How to commit and push to a private repo(A), from a different repo(B), in github actions workflow (B) , using personal access token 个人访问令牌不适用于 git 命令行 - Personal access token is not working for git command line
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM