<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TheElitist &#187; Revision Control (GIT/SVN)</title>
	<atom:link href="http://theelitist.net/category/how-to/revision-control-gitsvn/feed/" rel="self" type="application/rss+xml" />
	<link>http://theelitist.net</link>
	<description>Ventures of a Gamer/Programmer</description>
	<lastBuildDate>Tue, 07 Sep 2010 12:01:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>GIT: Change revision author&#8217;s email/name</title>
		<link>http://theelitist.net/git-change-revision-author/</link>
		<comments>http://theelitist.net/git-change-revision-author/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 18:53:44 +0000</pubDate>
		<dc:creator>Xeross</dc:creator>
				<category><![CDATA[How-To's]]></category>
		<category><![CDATA[Revision Control (GIT/SVN)]]></category>
		<category><![CDATA[author]]></category>
		<category><![CDATA[change]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[name]]></category>
		<category><![CDATA[revision]]></category>

		<guid isPermaLink="false">http://theelitist.net/?p=530</guid>
		<description><![CDATA[So recently I dived a little deeper into GIT, the best version control system in my opinion. however after making a few commits to a repository I created (For some modification to a program&#8217;s source code) I noticed it didn&#8217;t have my name on it as the author, and after 1 failed attempt of setting [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-917" style="margin: 7px;" title="GIT" src="http://theelitist.net/wp-content/uploads/2009/10/GIT.gif" alt="" width="108" height="24" />So recently I dived a little deeper into <a rel="external" href="http://en.wikipedia.org/wiki/Git_%28software%29">GIT</a>, the best version control system in my opinion. however after making a few commits to a repository I created (For some modification to a program&#8217;s source code) I noticed it didn&#8217;t have my name on it as the author, and after 1 failed attempt of setting the name/email the their values of commits after that were even worse.</p>
<p>So I needed a way to change the author&#8217;s name and email on the commits, after searching a little using google I encountered <a rel="external" href="http://github.com/guides/change-author-details-in-commit-history">this</a> page on <a rel="external" href="http://github.com">GitHub</a>, however I&#8217;ve decided to write a tutorial on it anyways, we&#8217;ll use the code from GitHub though.</p>
<p>Ok to do this we are going to use a bash script (which is basically a  list of commands to execute) they&#8217;re work on linux and also on windows if you have msysgit. here&#8217;s the code.</p>
<pre class="brush:bash">git filter-branch --env-filter '

an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"

if [ "$GIT_COMMITTER_EMAIL" = "EMAIL_OF_COMMITER_HERE" ]
then
    cn="NEW_NAME_COMMITER"
    cm="NEW_EMAIL_COMMITER"
fi
if [ "$GIT_AUTHOR_EMAIL" = "EMAIL_OF_AUTHOR_HERE" ]
then
    an="NEW_NAME_AUTHOR"
    am="NEW_EMAIL_AUTHOR"
fi

export GIT_AUTHOR_NAME="$an"
export GIT_AUTHOR_EMAIL="$am"
export GIT_COMMITTER_NAME="$cn"
export GIT_COMMITTER_EMAIL="$cm"
'</pre>
<p>As you can see this code uses the git filter-branch command, and everything on line 2-22 is basically the filter code. Now to replace a certain commiter or author just replace EMAIL_OF_AUTHOR/COMMITER_HERE with the email of that committer/author, and replace NEW_NAME_COMMITER/AUTHOR and NEW_EMAIL_COMMITER/AUTHOR with the new email and name you want him/her to have. You can replace multiple commiters/authors by copy-pasting the if blocks (See below for that part)</p>
<pre class="brush:bash">if [ "$GIT_COMMITTER_EMAIL" = "EMAIL_OF_COMMITER_HERE" ]
then
    cn="NEW_NAME_COMMITER"
    cm="NEW_EMAIL_COMMITER"
fi
if [ "$GIT_AUTHOR_EMAIL" = "EMAIL_OF_AUTHOR_HERE" ]
then
    an="NEW_NAME_AUTHOR"
    am="NEW_EMAIL_AUTHOR"
fi</pre>
<p>You can duplicate these for as many authors/commiters you want to replace. now after you finished this document save it somewhere you can access it easily (From the command line/console), and after that go inside your git repository&#8217;s folder (Ofcourse also on the command line aka console), when in there type the following.</p>
<pre class="brush:bash">sh /path/to/previous/saved/script.ext</pre>
<p>When you&#8217;ve done that a progress counter will start to run, this is the git filter-branch scanning through all your commits. After this process finishes your repo will be updated with the new name/email (use &#8220;git log&#8221; to check), now to push it to a remote repository push like normal but instead of &#8220;git push&#8221; use &#8220;git push -f&#8221;, after this is done your remote repo is also updated.</p>
<p>Well that&#8217;s it, hope it was useful and if you have any questions or remarks don&#8217;t hesitate to post a comment <img src='http://theelitist.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Regards, Xeross</p>
]]></content:encoded>
			<wfw:commentRss>http://theelitist.net/git-change-revision-author/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
