6

I have a linux machine running with Git. I did a checkout of a repo and I do commits from the linux commnad line. When I do push and pull operations, it asks me my username and password, and then it shows success.

However, in logs, it shows committed by root. I checked in git config, and I could not find anything.

Here are the values of my config file:

core.repositoryformatversion=0 
core.filemode=false
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=https://github.com/my-username/RepositoryName.git
branch.stage.remote=origin
branch.stage.merge=refs/heads/stage
Rahul Sonar
  • 69
  • 1
  • 3

1 Answers1

11

You need to set your user.name and your.email

git config --global user.name xxx
git config --global user.email xxx@mail.com

If you only did one commit, you can amend it:

git commit --amend --author "New Author Name <email@address.com>"

See more at "Change the author of a commit in Git".

If you did several commit, you would need to rewrite those (see "Change commit author at one specific commit")

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hi VonC, Thanks for the reply. But I am not the only person who do commits. Other people will also do pull and push from that same repository... In that case, I cant set my username there. – Rahul Sonar Aug 16 '14 at 14:53
  • Those settings are only for your repo, when logged as you. Others will have their settings – VonC Aug 16 '14 at 14:59
  • Note that the even if git config --list has both the user.name and user.email listed, the command in the answer may still be necessary. I think it's the --global flag that makes the difference – tjb Oct 19 '18 at 03:21