如何临时更改远程推送的 git ssh 用户? [英] How to change git ssh user for a remote push temporarily?

查看:20
本文介绍了如何临时更改远程推送的 git ssh 用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以临时更改git push remote master"的 ssh 用户而不会弄乱 .git/config 或git remote",或者使用整个远程 url?

Is it possible to change the ssh user temporarly for a "git push remote master" without messing up with .git/config or "git remote", or using the whole remote url?

[root@host gitrepo]# git push otheruser@remote master # this does not work, but how great it would be
[root@host gitrepo]# USER=otheruser git push remote master # still asks password for root

推荐答案

您是否尝试过使用整个远程 URL?

Have you tried using the whole remote URL?

git push ssh://<temp_user>@<host>/<repo_path> <local_branch>:<remote_branch>

系统会提示您提供密码

这篇关于如何临时更改远程推送的 git ssh 用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆