我以 userA 身份登录到一台计算机。
$ git remote -v
origin git:/git/repo/code.git (fetch)
origin git:/git/repo/code.git (push)
Run Code Online (Sandbox Code Playgroud)
当我执行“git fetch origin”时,它要求输入 userA 的密码。
是否可以以 userB 身份在 git 服务器上获取?
谢谢。
根据gitcredentials 文档中的“凭据上下文” ,您可以添加 git 配置文件:
[credential "git:/git/repo/code.git"]
username = userB
Run Code Online (Sandbox Code Playgroud)
这样就可以了。
实现您想要的目标的其他方法是更换遥控器:
git config remote.origin.url https://userB:password@example.com/repo.git
Run Code Online (Sandbox Code Playgroud)
但你需要有一个存储库的 http url。
| 归档时间: |
|
| 查看次数: |
2728 次 |
| 最近记录: |