Chris Wesseling
Chris Wesseling

Reputation: 6368

What's the git equivalent of hg commit -u?

I'm logged in on a shared account and want to commit some change quickly under my own identity.

With Mercurial I would do it with the -u flag

-u --user USER record the specified user as committer

hg commit -u '[email protected]'

I tried

git commit --author='John Doe <[email protected]>'

but doesn't help.

Since the account is shared, this doesn't help Using same git repository by multiple users

Is using git config and then removing it when I'm done really the only way?

Upvotes: 1

Views: 214

Answers (3)

Vampire
Vampire

Reputation: 38639

With -c you can override any Git config setting on the commandline. So just do it like

git -c user.name="John Doe" -c [email protected] commit

Upvotes: 3

shazzing
shazzing

Reputation: 441

So the other option other than what @pedro indicated is to update your git config(especially if you want to commit more).

git config user.name "Your Name Here" 
git config user.email [email protected]

if git cannot recognize your email, you will have to follow the below to add the email to your git identity. https://help.github.com/articles/why-are-my-commits-linked-to-the-wrong-user/

Upvotes: 0

Pedro Nascimento
Pedro Nascimento

Reputation: 13886

Commit normally and then amend with the author:

git commit --amend --author="Author Name <[email protected]>"

Upvotes: 0

Related Questions