简体   繁体   English

git fetch origin 使用 https 和令牌失败

[英]git fetch origin using https and token fails

I can fetch the origin by navigating to the folder and:我可以通过导航到文件夹来获取原点,然后:

git fetch origin

And then execute:然后执行:

git diff origin/master --name-only

Which shows me the files on the server that are not the same as the local files which is what I am looking for.这向我显示了服务器上与我正在寻找的本地文件不同的文件。

But I cannot find the correct syntax to do this via https using a token, I have looked at the help page ( https://help.github.com/articles/fetching-a-remote/ ) and there seems to be nothing there that describes how to do this.但是我找不到使用令牌通过 https 执行此操作的正确语法,我查看了帮助页面( https://help.github.com/articles/fetching-a-remote/ ),但似乎没有任何内容这描述了如何做到这一点。

This does not error, but it does not appear fetch the same way as the command above does and executing 'git diff' does not correctly show the files.这不会出错,但它的获取方式与上述命令不同,并且执行 'git diff' 未正确显示文件。

git fetch https://5e99326e6f628dxxxxx@github.com/myname/repo.git :origin

So how can I use a token to fetch the origin ?那么如何使用令牌来获取原点呢?

EDIT编辑

To avoid confusion, the request is succesfull and there is no problem with authentication that works, however the url that I use does NOT enable me to issue the git diff command afterwards and see a list of files that are different on the server.为了避免混淆,请求是成功的,并且身份验证没有问题,但是我使用的 url 不允许我在之后发出 git diff 命令并查看服务器上不同的文件列表。

If I use the first command "git fetch origin" then I am able to see the dirfferences, use the second https command and I cannot see the differences,如果我使用第一个命令“git fetch origin”,那么我可以看到目录,使用第二个 https 命令,我看不到差异,

So to re-summarise:所以重新总结一下:

git fetch origin
git diff origin/master --name-only
> changed files ARE shown


git fetch https://5e99326e6f628dxxxxx@github.com/myname/repo.git :origin
git diff origin/master --name-only
> changed files are NOT shown

I want to execute git fetch origin without being prompted for username and p password and use the oauth token instead我想在不提示输入用户名和 p 密码的情况下执行 git fetch origin 并改用 oauth 令牌

First, unless you are using 2FA ( Securing your account with two-factor authentication (2FA) ), you don't need a token.首先,除非您使用 2FA( 使用双因素身份验证 (2FA) 保护您的帐户) ,否则您不需要令牌。
A git credential helper would be enough to cache your credentials.一个git 凭证助手就足以缓存您的凭证。

Second, considering the OAuth token section , try with username:token.其次,考虑到OAuth 令牌部分,尝试使用 username:token。
(Meaning token as a password) (意思是token作为密码)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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