{"componentChunkName":"component---src-templates-blog-post-js","path":"/20180317-git--rewrite-author","result":{"data":{"site":{"siteMetadata":{"title":"dfaiv-dev","siteUrl":"https://blog.dfaiv.dev"}},"markdownRemark":{"id":"4600aa31-af6a-561f-890c-94ad8d5892b6","excerpt":"On my computer, my default git user is for my work account. I was working on a personal project, pushed it to GitHub, and didn’t realize until after that I had…","html":"<p>On my computer, my default git user is for my work account. I was working on a personal project, pushed it to GitHub, and didn’t realize until after that I had been commiting with my work username/email. Some Googling <a href=\"https://stackoverflow.com/questions/750172/how-to-change-the-author-and-committer-name-and-e-mail-of-multiple-commits-in-gi\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">turned up</a> that you can rewrite history from one email/username to another:</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">git</span> filter-branch --env-filter <span class=\"token string\">'\nOLD_EMAIL=\"your-old-email@example.com\"\nCORRECT_NAME=\"Your Correct Name\"\nCORRECT_EMAIL=\"your-correct-email@example.com\"\nif [ \"<span class=\"token variable\">$GIT_COMMITTER_EMAIL</span>\" = \"<span class=\"token variable\">$OLD_EMAIL</span>\" ]\nthen\n    export GIT_COMMITTER_NAME=\"<span class=\"token variable\">$CORRECT_NAME</span>\"\n    export GIT_COMMITTER_EMAIL=\"<span class=\"token variable\">$CORRECT_EMAIL</span>\"\nfi\nif [ \"<span class=\"token variable\">$GIT_AUTHOR_EMAIL</span>\" = \"<span class=\"token variable\">$OLD_EMAIL</span>\" ]\nthen\n    export GIT_AUTHOR_NAME=\"<span class=\"token variable\">$CORRECT_NAME</span>\"\n    export GIT_AUTHOR_EMAIL=\"<span class=\"token variable\">$CORRECT_EMAIL</span>\"\nfi\n'</span> --tag-name-filter <span class=\"token function\">cat</span> -- --branches --tags</code></pre></div>\n<p>I got a nasty warning, but after a few seconds it proceeded with the rewrite and the world didn’t seem to end. I guess I could have tried the <a href=\"https://github.com/newren/git-filter-repo/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">suggested alternative</a>, but I only had a few commits and the rewrite seemed mostly innocuous.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">WARNING: git-filter-branch has a glut of gotchas generating mangled history\n         rewrites.  Hit Ctrl-C before proceeding to abort, then use an\n         alternative filtering tool such as &#39;git filter-repo&#39;\n         (https://github.com/newren/git-filter-repo/) instead.  See the\n         filter-branch manual page for more details; to squelch this warning,\n         set FILTER_BRANCH_SQUELCH_WARNING=1.</code></pre></div>\n<p>A <code class=\"language-text\">git push --force</code> and my repo commits were updated with my personal email.</p>","frontmatter":{"title":"git - Rewrite authors","date":"March 17, 2018","description":"","slug":"20180317-git--rewrite-author"}},"previous":{"frontmatter":{"title":"TMUX, WSL, Copy & Paste with Mouse","slug":"20180102-env--tmux-copy-paste"}},"next":{"frontmatter":{"title":"Powershell - Write-Host from Background Script Block","slug":"/20180723-ps-write-host-from-background-script-block"}}},"pageContext":{"id":"4600aa31-af6a-561f-890c-94ad8d5892b6","previousPostId":"cc716f6d-7015-5935-91b2-c61b2ee0170d","nextPostId":"82112752-eb70-5ec5-a242-2f7f77ae510d"}},"staticQueryHashes":["2841359383","3825813668"]}