How to change user identity when git pushing via s

2019-06-06 20:12发布

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}"')

I created a new ssh key on my EC2 instance, adding it as a deploy key on the GitHub repo and allowed write access.

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?

1条回答
我命由我不由天
2楼-- · 2019-06-06 20:41

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

It has to do with the current Git config:

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.

查看更多
登录 后发表回答