John Doe John Doe - 1 year ago 59
Node.js Question

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?

Answer Source

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
git config

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.