简体   繁体   English

通过SSH推送时如何更改用户身份?

[英]How to change user identity when git pushing via ssh?

So I am trying to set up some automated git pushing/pulling on an EC2 instance. 因此,我试图在EC2实例上设置一些自动化的git push / pulling。 Doing this super simply via Node: 只需通过Node即可做到这一点:

var add = require('child_process').execSync('git add {FILENAME})
var commit = require('child_process').execSync('git commit -m "{COMMIT_MESSAGE}"')

I created a new ssh key on my EC2 instance, adding it as a deploy key on the GitHub repo and allowed write access. 我在EC2实例上创建了一个新的ssh密钥,并将其作为部署密钥添加到GitHub存储库上,并允许写访问。

Everything is working perfectly, except the commit author is coming through as EC2 Default User . 一切工作正常,除了提交作者以EC2 Default User身份通过。 I would like it to be my own GitHub account , so that the commits appear on my profile, etc. How is this possible? 我希望它是我自己的GitHub帐户 ,以便这些提交显示在我的个人资料上,等等。这怎么可能?

The commit author has nothing to do with which ssh key is used to authenticate the push. 提交作者与使用ssh密钥对推送进行身份验证无关。

It has to do with the current Git config: 它与当前的Git配置有关:

git config user.name
git config user.email

Make sure the values for those local settings are correct (local for the EC2 Git repo), and the next new commits will be with the right author. 确保这些本地设置的值正确(对于EC2 Git存储库为本地),并且下一次新提交将由正确的作者进行。

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

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