2

My last commit was displayed with my organization name and email as committer on Github. After little research, I found many tweaks and tried these commands to change name & email in the last commit:

git -c user.name="my_name" -c user.email=my_email_address commit --amend --reset-author
git commit --amend --author "my_name <my_email_address>"

These commands worked perfectly but after merging the code, I just noticed that again my organization name is displayed with the last merge commit.

  • Why my commits uses organization name & email rather than my name & email?
  • Suggest me the best possible way to change name and email for the last merge and that may use the same (new) name/email for next commits.
  • Is there any way to specify the name & email with every individual commit to end this confusion?
Adil
  • 21,278
  • 7
  • 27
  • 54

1 Answers1

1

You can check your config with:

git config --show-origin -l

That way, you can check all the config files which might contain your user.name and user.email

In your repo, make sure to set the right user and email you want

cd /path/to/my/repo
git config user.name xxx
git config user.email xxx

If you don't any new commit (done after amending your old commits) would still be created with the old information.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks @VonC but didn't get the last statement, seems there's some typo. First command displayed error _unknown option `show-origin'_. – Adil Aug 04 '16 at 07:56
  • 1
    @Mambro you need Git 2.8 or more. Update Git: http://unix.stackexchange.com/a/170831/7490 – VonC Aug 04 '16 at 07:57
  • Upgraded to 2.9.2 and now the command worked. Yes its showing my organization name & email in .gitconfig. Wouldn't changing username/email in this way will change for other git projects also as I've some official git projects placed besides this project in the root directory and I do commit there with official (organization's) username? Isn't there any way that I can define which username/email I wanna use for which project? – Adil Aug 04 '16 at 08:10
  • 1
    @Mambro if you want to define your user and email just for one git repo, see my answer: that local setting will apply *only* for that repo. – VonC Aug 04 '16 at 08:11
  • 1
    @Mambro also, interesting read: https://help.github.com/articles/keeping-your-email-address-private/ – VonC Aug 04 '16 at 08:13
  • Thanks for that ^ interesting read as I was going to ask which email to display either public or private? – Adil Aug 04 '16 at 08:47
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/120089/discussion-between-mambro-and-vonc). – Adil Aug 04 '16 at 08:56