通过ssh进行git push时如何更改用户身份? [英] How to change user identity when git pushing via ssh?

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

问题描述

因此,我尝试在EC2实例上设置一些自动git push/pulling.只需通过Node即可做到这一点:

So I am trying to set up some automated git pushing/pulling on an EC2 instance. Doing this super simply via Node:

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

我在EC2实例上创建了一个新的ssh密钥,将其添加为GitHub存储库上的部署密钥,并允许写访问.

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 Default User身份通过.我希望它是我自己的GitHub帐户,以便将提交显示在我的个人资料上,等等.这怎么可能?

Everything is working perfectly, except the commit author is coming through as 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?

推荐答案

提交作者与使用ssh密钥对推送进行身份验证无关.

The commit author has nothing to do with which ssh key is used to authenticate the push.

它与当前的Git配置有关:

It has to do with the current Git config:

git config user.name
git config user.email

确保这些本地设置的值正确(对于EC2 Git存储库为本地),并且下一次新提交将由正确的作者进行.

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.

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

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