<?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>GitHub &#8211; nood1es</title>
	<atom:link href="https://yijie.lu/tag/github/feed/" rel="self" type="application/rss+xml" />
	<link>https://yijie.lu</link>
	<description>Rick&#039;s Blog</description>
	<lastBuildDate>Thu, 18 May 2017 06:53:16 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.2.4</generator>

<image>
	<url>https://yijie.lu/wp-content/uploads/2017/05/411.png</url>
	<title>GitHub &#8211; nood1es</title>
	<link>https://yijie.lu</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>找回GitHub消失的contributions</title>
		<link>https://yijie.lu/retrieve-the-github-contributions/</link>
				<comments>https://yijie.lu/retrieve-the-github-contributions/#respond</comments>
				<pubDate>Thu, 20 Apr 2017 06:46:34 +0000</pubDate>
		<dc:creator><![CDATA[Rick Lu]]></dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[GitHub]]></category>

		<guid isPermaLink="false">https://yijie.lu/?p=13</guid>
				<description><![CDATA[<p>作为世界上最大同性交友网站——GitHub 😂 自从入了坑，天天想着push代码。之前Yumeer的项目本来在 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://yijie.lu/retrieve-the-github-contributions/">找回GitHub消失的contributions</a> appeared first on <a rel="nofollow" href="https://yijie.lu">nood1es</a>.</p>
]]></description>
								<content:encoded><![CDATA[<p>作为世界上最大同性交友网站——GitHub <img src="https://s.w.org/images/core/emoji/12.0.0-1/72x72/1f602.png" alt="😂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>自从入了坑，天天想着push代码。之前Yumeer的项目本来在Coding上，后来嫌弃它不够洋气，就换到GitHub上来了，搭建好仓库，配置好ssh，开始安心写代码。commit一两次后，我发现我的contributions并没有被点亮啊，一开始以为是私有仓库的原因，没去管。直到最近突然发现我一直设置的是展现所有项目。几番寻找，后来发现了问题——为了方便pull/push。我使用了SSH，在公司里面，我配置成Rick@Work，家里配置成了Rick@Home。push代码的时候，GitHub无法匹配账户信息，默认判断为新用户提交，这也就造成了最后无法count进自己的contributions。</p>
<p><span id="more-13"></span></p>
<p>根据GitHub官方的解决方案如下：</p>
<p>0.确定你错误的和正确的username/email信息（正确信息直接在GitHub profile里面找，错误的如果不知道，先执行下一步）</p>
<p>1.Clone一个临时仓库</p>
<pre class="EnlighterJSRAW" data-enlighter-language="shell">git clone --bare https://github.com/your-account/your-repo.git
cd your-repo.git</pre>
<p>如果不知道错误信息可以在完成第一步后通过git log命令获取</p>
<p>2.运行以下脚本</p>
<p><em>注意：替换脚本中的your-old-email@example.com/Your Correct Name/your-correct-email@example.com</em></p>
<pre class="EnlighterJSRAW" data-enlighter-language="shell">#!/bin/sh

git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags</pre>
<p>这里，就是一个简单的fliter——通过判定旧的git.config.email来更改每次commit的作者信息。同理，可以使用git.config.name来实现目的（更推荐，因为邮箱可能重复）</p>
<pre class="EnlighterJSRAW" data-enlighter-language="shell">#!/bin/sh

git filter-branch --env-filter '
OLD_NAME="your-old-name"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_NAME" = "$OLD_NAME" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_NAME" = "$OLD_NAME" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
</pre>
<p>3.运行后，会提示多少commit被修改，然后直接push</p>
<pre class="EnlighterJSRAW" data-enlighter-language="shell">git push --force --tags origin 'refs/heads/*'</pre>
<p>到此为止搞定，去check一下。最后记得rm刚刚的临时仓库。</p>
<p><img class="size-full wp-image-15 aligncenter" src="https://yijie.lu/wp-content/uploads/2017/05/屏幕快照-2017-05-18-下午2.47.59.png" alt="" width="754" height="208" /></p>
<p>Enjoy！：P</p>
<p>The post <a rel="nofollow" href="https://yijie.lu/retrieve-the-github-contributions/">找回GitHub消失的contributions</a> appeared first on <a rel="nofollow" href="https://yijie.lu">nood1es</a>.</p>
]]></content:encoded>
							<wfw:commentRss>https://yijie.lu/retrieve-the-github-contributions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
	</channel>
</rss>
