[英]How do I suppress the repository url when pushing or pulling with git?
I have a repository that has a remote to azure-devops.我有一个存储库,它有一个到 azure-devops 的遥控器。
I have to go through a proxy if that matters, but that's setup and working correctly.如果这很重要,我必须通过代理,但设置和工作正常。 I don't think this will be an issue for this question.
我认为这不会成为这个问题的问题。
You can add a token to the remote url (in the form of https://user:pat@dev.azure.com/.. .), which I do because copy-n-pasting the pat every single time is annoying.您可以向远程 url 添加令牌(以https://user:pat@dev.azure.com/..的形式),我这样做是因为每次复制粘贴 pat 很烦人。
When pushing or pulling, the full url is displayed.推或拉时,会显示完整的 url。
$ git push azure dev
Counting objects: 3, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 279 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Analyzing objects... (2/2) (163 ms)
remote: Storing packfile... done (177 ms)
remote: Storing index... done (31 ms)
To https://user:mypat@dev.azure.com/user/path/to/repo <<<---
b20e4fd..b1772a1 dev -> dev
How can I suppress the 'To https...' line?如何抑制“To https ...”行?
Edit : This is not a duplicate, because that answer changes authentication protocol to ssh keys.编辑:这不是重复的,因为该答案将身份验证协议更改为 ssh 密钥。 Because I have to use a proxy (see second paragraph) I can't use ssh keys.
因为我必须使用代理(参见第二段),所以我不能使用 ssh 密钥。
@ochi pointed to a comment on another, similar question. @ochi 指出了对另一个类似问题的评论。 The following comment held my answer.
以下评论保留了我的答案。
Using .netrc
to hold my authentication information works as desired.使用
.netrc
来保存我的身份验证信息可以正常工作。 Make sure to chmod 0600 ~/.netrc
or it won't work.确保
chmod 0600 ~/.netrc
否则它不会工作。
machine dev.azure.com
login user
password personalaccesstoken
This is the output I'm getting now.这是我现在得到的输出。
$ git push azure test
Counting objects: 3, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 289 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Analyzing objects... (2/2) (126 ms)
remote: Storing packfile... done (244 ms)
remote: Storing index... done (95 ms)
To https://dev.azure.com/user/path/to/repo <<<---
24a77ad..5ee5fcb HEAD -> test
Updated更新
As pointed out in the comments, this is not a perfect solution.正如评论中指出的那样,这不是一个完美的解决方案。 The
.netrc
file is used by other applications and this information will be available to them. .netrc
文件由其他应用程序使用,并且这些信息可供他们使用。 This works in my situation, you should evaluate yours and decide if this is what you want.这在我的情况下有效,您应该评估您的情况并决定这是否是您想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.