<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>pizzq</title>
    <link>https://ruby-china.org/pizzq</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>解决因 Author 中有特殊字符引起的 push 失败</title>
      <description>&lt;p&gt;今天打算同步 RubyChina 的 source code，但在 merge 到本地的 branch 后，push 到 github 时确碰到了问题，错误如下：&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Pushing to https://github.com/hunkshi/ruby-china.git
error: unpack failed: index-pack abnormal exit&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;通过 googgle 搜索，有人建议 check 一下数据库，fsck-objects 显示，果然有一条错误&lt;/p&gt;

&lt;p&gt;error in commit 0c804057994a56a1d649653675365b3ad12d7ad8: invalid author/committer line - bad name&lt;/p&gt;

&lt;p&gt;在 history 中找到这条 commit，发现这条 commit 的 Author、Committer 中&lt;strong&gt;有特殊字符=&amp;gt; /&lt;/strong&gt;, 为了验证是否因为这些特殊字符引起，从这条 commit 的上一条建了一个 branch，push 到 github，成功！把之后的 commit merge 过来再次上传，失败！因此可以断定是特殊字符引起。&lt;/p&gt;

&lt;p&gt;解决办法，Git Bash 中运行如下命令：&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git filter-branch -f --commit-filter '
    if [ "$GIT_AUTHOR_EMAIL" = "xxx@gmail.com" ];
    then
       GIT_AUTHOR_NAME="xxxxx";
       GIT_COMMITTER_NAME="xxxxxx";
       git commit-tree "$@";
  else
      git commit-tree "$@";
  fi
' HEAD&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;xxxx 为去除特殊字符的新 name。然后 push 到 github（选择 force 选项，强制覆盖），成功！&lt;/p&gt;

&lt;p&gt;我使用 git 和 github 时间还不长，有以下一些疑问：&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;大家碰到过类似的问题吗？怎么解决的？是否有简单办法？&lt;/li&gt;
&lt;li&gt;Git 对 Author、Committer 名字有规范吗？可以使用&amp;gt; /这样的字符吗？&lt;/li&gt;
&lt;/ol&gt;</description>
      <author>pizzq</author>
      <pubDate>Sat, 21 Jul 2012 19:19:55 +0800</pubDate>
      <link>https://ruby-china.org/topics/4466</link>
      <guid>https://ruby-china.org/topics/4466</guid>
    </item>
  </channel>
</rss>
