我按照这些说明来写信,包括有关密码缓存的部分.似乎说明是错误的,因为每次git push origin master我收到此错误:
git: 'credential-cache' is not a git command. See 'get --help'.
Run Code Online (Sandbox Code Playgroud)
...此时我被迫输入我的用户名和密码.这样做之后,我再次收到相同的错误消息,然后是输出git push.
这是我的.gitconfig文件的内容:
[user]
name = myusername
email = myusername@myemaildomain.com
[credential]
helper = cache
Run Code Online (Sandbox Code Playgroud)
要清楚,在我安装Git并运行Git Bash之后,这就是我输入的内容:
git config --global user.name "myusername"
git config --global user.email "myusername@myemaildomain.com"
git config --global credential.helper cache
Run Code Online (Sandbox Code Playgroud)
请帮忙.这太令人沮丧了!
我想通过使用我的gitlab帐户中的私有令牌来克隆gitlab存储库而不提示我的自动化脚本.
有人能为我提供样品吗?
我知道我可以使用用户和密码这样做:
git clone https://" + user + ":" + password + "@" + gitlaburl;
Run Code Online (Sandbox Code Playgroud)
我知道用ssh键是可能的
但是,这两种选择都不够
使用经典的Github 代币,您可以像这样克隆一个存储库:
git clone https://<your-token>@github.com/owner/repo.git
Run Code Online (Sandbox Code Playgroud)
这不适用于新的细粒度令牌。
如何使用新的细粒度令牌克隆 GitHub 存储库?
我有一个托管在 gitlab.com 上的私人存储库。我创建了一个具有read_repository范围的项目访问令牌。目的是任何拥有项目访问令牌的用户都可以克隆存储库。
我发出:
git clone https://xyz@gitlab.com/user/repo.git
Run Code Online (Sandbox Code Playgroud)
当提示输入密码时,我输入项目访问令牌,但被告知:
Cloning into 'repo'...
Password for 'https://xyz@gitlab.com':
remote: You are not allowed to download code from this project.
fatal: unable to access 'https://gitlab.com/user/repo.git/': The requested URL returned error: 403
Run Code Online (Sandbox Code Playgroud)
除了 之外,我还尝试创建许多具有多个范围的附加项目访问令牌read_repository,但出现相同的错误。我还尝试直接在克隆中使用项目访问令牌进行克隆:
git clone https://xyz:MY_ACCESS_TOKEN@gitlab.com/user/repo.git
Run Code Online (Sandbox Code Playgroud)
但得到同样的错误。
澄清
我创建的所有项目访问令牌的到期日期都设置为从现在起一个月。xyz据我了解,该字符串是无关紧要的,因为它是用户名的占位符。从 gitlab 文档来看,这似乎可以是任何非空字符串。