0

I frequently commit code to a repository at work using git from several devices (desktop PC, laptop, etc.). The desktop PC (in-office) automatically configured my identity when I pulled that repository. However, I have used my laptop for personal projects before and have globally configured my user.name and user.email to different values. When I commit code to the work repo from my laptop, the commit's author is different from when I commit from the desktop PC.

I want to sync the identity from my desktop PC to my laptop, that is, to make sure the author remains the same. Is setting user.name and user.email enough? Does git determine a commit's author using other means?

selamba
  • 321
  • 3
  • 9
  • 2
    Git determines the commit author by `git config` this can be at the global, system, worktree (repo), and file levels. https://git-scm.com/docs/git-config – evolutionxbox Feb 07 '22 at 12:50
  • There are many fields in .git/config. What fields does git use to determine the author? – selamba Feb 07 '22 at 13:17
  • 1
    https://git-scm.com/docs/git-config#Documentation/git-config.txt-username `user.name` and `user.email`, although you can specify author and committer to be different – evolutionxbox Feb 07 '22 at 13:39
  • You should make this the answer – selamba Feb 07 '22 at 13:40
  • 1
    I'm fairly confident this has been asked before. I'm just trying to find it. https://stackoverflow.com/questions/18750808/difference-between-author-and-committer-in-git could be a match, but it's not close enough – evolutionxbox Feb 07 '22 at 13:40
  • Duplicate: https://stackoverflow.com/questions/4220416/can-i-specify-multiple-users-for-myself-in-gitconfig – ParSal Feb 07 '22 at 16:56
  • @ParSal no it isn't – selamba Feb 09 '22 at 06:04
  • It is not the duplicate of your question, but it is the answer. :D You can specify a user at global level, and you can override it per git directory. – ParSal Feb 09 '22 at 06:24

0 Answers0