{"thread":{"id":"16845","subject":"Can `git config` override entries in .gitconfig?","startedAt":"2008-12-23T12:05:46Z","lastAt":"2008-12-23T17:59:13Z","messageCount":2,"participants":["Nicholas LaRoche","Johan Herland"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"98601","messageId":"4950D41A.5050009@vt.edu","threadId":"16845","inReplyTo":null,"subject":"Can `git config` override entries in .gitconfig?","fromName":"Nicholas LaRoche","fromEmail":"nlaroche@vt.edu","sentAt":"2008-12-23T12:05:46Z","receivedAt":"2008-12-23T12:05:46Z","isPatch":false,"sender":{"key":"nlaroche@vt.edu","avatar":null},"body":"Is there a direct way to change the user.email entry for a git \nrepository for one user (applied to all previous commits)?\n\nI tried `git config --unset user.email` followed by `git config \nuser.email email2` but it just sets a second field called user.email \nthat shows up in `git config -l` as a duplicate. My ~/.gitconfig file \ncontains email1 for the user.email entry.\n\nAlso, when the repository is created can I specify a second set of \ncontact information (i.e. using a project specific email) which isn't a \npart of ~/.gitconfig?\n\noutput of `git config -l`:\nuser.email=email1\n..\n..\nuser.email=email2\n\nRegards,\nNick\n"},{"id":"98628","messageId":"200812231859.13619.johan@herland.net","threadId":"16845","inReplyTo":"4950D41A.5050009@vt.edu","subject":"Re: Can `git config` override entries in .gitconfig?","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-12-23T17:59:13Z","receivedAt":"2008-12-23T17:59:13Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Tuesday 23 December 2008, Nicholas LaRoche wrote:\n> Is there a direct way to change the user.email entry for a git\n> repository for one user (applied to all previous commits)?\n>\n> I tried `git config --unset user.email` followed by `git config\n> user.email email2` but it just sets a second field called user.email\n> that shows up in `git config -l` as a duplicate. My ~/.gitconfig file\n> contains email1 for the user.email entry.\n>\n> Also, when the repository is created can I specify a second set of\n> contact information (i.e. using a project specific email) which isn't a\n> part of ~/.gitconfig?\n>\n> output of `git config -l`:\n> user.email=email1\n> ..\n> ..\n> user.email=email2\n\nHi,\n\nUse git-config's --global option to set options in your ~/.gitconfig. \nOtherwise, your config changes are stored in the current repo's config \n(.git/config).\n\nIn your case, when you did `git config --unset user.email`, you unset the \n(non-existing) user.email in your repo config, without touching the one in \n~/.gitconfig, and when you did `git config user.email email2`, you set \nuser.email in the repo config (without changing the one in your \n~/.gitconfig).\n\nAlthough `git config -l` displays options from both ~/.gitconfig and the \nrepo config, AFAIK the repo config does _override_ the ~/.gitconfig, so \nwhen you have user.email set in both, your new commits will use the one in \nthe repo config (i.e. \"email2\").\n\nAs for rewriting your email address in all previous commits, that is \nimpossible to do without rewriting your entire history. Rewriting your \nhistory is probably not something you want to do if you have published your \nrepo, and other people have started working on top of your commits. If you \n_do_ want to rewrite your history, you should look at the \"git \nfilter-branch\" command.\n\n\nHave fun!\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"}]}