简体   繁体   中英

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. 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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