使用 https 和 token 获取 git fetch origin 失败

标签 git

我可以通过导航到文件夹来获取源:

git fetch origin

然后执行:

git diff origin/master --name-only

这显示了服务器上与我正在寻找的本地文件不同的文件。

但是我找不到使用 token 通过 https 执行此操作的正确语法,我查看了帮助页面 ( https://help.github.com/articles/fetching-a-remote/ ),那里似乎没有任何内容描述如何执行此操作。

这不会出错,但它的 fetch 方式与上面的命令不同,并且执行“git diff”无法正确显示文件。

git fetch https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1722722e2e24252172217121252f736f6f6f6f6f57707e637f62753974787a" rel="noreferrer noopener nofollow">[email protected]</a>/myname/repo.git :origin

那么我如何使用 token 来获取原点?

编辑

为了避免混淆,请求是成功的,并且身份验证没有问题,但是我使用的 url 不允许我随后发出 git diff 命令并查看服务器上不同的文件列表.

如果我使用第一个命令“git fetch origin”,那么我可以看到差异,使用第二个 https 命令,我看不到差异,

重新总结一下:

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


git fetch https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3c095905050f0e0a590a5a0a0e045844444444447c5b554854495e125f5351" rel="noreferrer noopener nofollow">[email protected]</a>/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

首先,除非您使用 2FA ( Securing your account with two-factor authentication (2FA) ),否则不需要 token 。
一个git credential helper足以缓存您的凭据。

其次,考虑OAuth token section ,尝试使用用户名:token。
(意思是 token 作为密码)

关于使用 https 和 token 获取 git fetch origin 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48635841/

相关文章:

git - 如何刷新Gitlab Web界面

visual-studio-2010 - 在 Git Branch-A 中添加的文件在 Branch-B 中可见

Git Rebase 冲突 : Who is HEAD?

git 快进一次提交

iphone - Git: iOS 创建一个实验性的 iPad 分支

windows - git 在文件路径中带有括号的文件上添加补丁

git - 为什么我会收到错误 : RPC failed; result=52, HTTP code = 0 fatal : The remote end hung up unexpectedly when pushing to github?

Git Stash 同时保留被忽略的文件

git.exe 在 Windows 上突然消失了

javascript - meteor JS : Installing on apache/linux server