简体   繁体   English

git用一个用户名推送,用另一个用户名推送

[英]git push with one username, pull with another

I'm using Git to deploy code onto a server with multiple branches for live and staging setups. 我正在使用Git将代码部署到具有多个分支的服务器上,以进行实时和临时安装。 I'd like to build a simple web interface for pulling without password, but for security reasons, I'd like to push only from command line with a password secured private key. 我想构建一个简单的Web界面来无需密码即可进行提取,但是出于安全原因,我只想从带有密码保护私钥的命令行进行推送。 I have set up two usernames, one of them read-only. 我设置了两个用户名,其中一个是只读的。

Is there a way to configure the clones repository on the server this way? 有没有一种方法可以在服务器上配置克隆存储库? I've seen the pushurl and remote.url entries in the configuration file, but can't see how I would specify a user for them. 我已经在配置文件中看到了pushurlremote.url条目,但是看不到如何为它们指定用户。

A more robust way of configuring read/write access would be to install on the server side an authorization layer like gitolite . 配置读写访问权限的一种更可靠的方法是在服务器端安装一个授权层,gitolite

Then you can setup your 2 usernames in order for one to clone only, the other to push (to the full repo or only to certain branches). 然后,您可以设置2个用户名,以便一个只能克隆,另一个可以推送(到完整存储库或仅到某些分支)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM