0

I have set the local user config using following command,

git config user.name "Ankur Tank"
git config user.email "ankur.tank@example.com"

git config --global is set for different user.

When I do git push, I see it is being pushed with global user name and email id.

How can I override global username and email? Is it possible ?
For git commit --author < > is possible but git push --author < > not available.

Any suggestions/pointer ?

Edit:
.git/config in my repo shows local user name what i have set. Even when i commit it takes local user name but for git push it take global user name and email.

ART
  • 1,509
  • 3
  • 29
  • 47
  • What does the .git/config look like for the repo? – Rob Jul 24 '15 at 15:29
  • did you set the local user settings while you are inside the local repo? – Ammadu Jul 24 '15 at 15:37
  • @Rob: Updated description. – ART Jul 24 '15 at 15:40
  • @Ammadu : Yes I had set local user setting while I was inside local repo. And then I copied the whole folder to other path and the `.git/config` shows local user name and email. – ART Jul 24 '15 at 15:43
  • The local user/email takes higher precedence than global settings. I just checked it in my configuration. It works perfectly fine. Either you are missing something or you are using an ancient version of git. – positron Jul 24 '15 at 22:36
  • 3
    When you `git log` , which author appears ? You might have committed under your global user and setup the local config after (push is for authentication, not ownership of commit) – topheman Jul 25 '15 at 00:41
  • 1
    Please see here for the difference between a committer and an author in Git: http://stackoverflow.com/questions/18750808/difference-between-author-and-committer-in-git - this might be what you're seeing here. – nwinkler Jul 25 '15 at 08:34
  • @positron : my git version is `git version 1.9.1`, I might be missing something but i don't know what. :( – ART Jul 27 '15 at 12:09
  • @topheman When I `git log`, I see my name(local user config), But when I do `git push` It pushes with global user name. :( – ART Jul 27 '15 at 12:10
  • @nwinkler: But when I `git log` I see local username(local user config), even `git log --pretty='%cn' -n1 HEAD` shows my name i.e. local username. So I assume in my case committer and an author is same, isn't it ? – ART Jul 27 '15 at 12:16
  • I think i found the cause, not sure though, I didn't mention but we are using ssh keys. SSH key stored is created for another user..does that create problem? Because temporarily i changed the `git config --global user.name ` and `git config --global user.email ` but still it show previous user while I do `git push origin` Now only difference is key. I will try to change it temporarily and see if that some effect. – ART Jul 29 '15 at 16:30

1 Answers1

1

After testing trying various combination, finally I found that root cause was ssh key. I followed steps in the another question Best way to use multiple SSH private keys on one client , I followed steps mentioned by Wahib Haq.

Here are steps
1. # ssh-agent bash
2. # ssh-add /path.to/private/key
To list added ssh private key we
3. # ssh-add -l

After that when I do git push it takes local config and update goes in my name.

Community
  • 1
  • 1
ART
  • 1,509
  • 3
  • 29
  • 47