前言:最近github上新建了一个项目,commits的比较多。某天突然发现,Contributions上还是空白一片。遂Google之,发现是由于commit时的邮箱是公司邮箱,所以Github就会认为这些commits都不是我提交的[捂脸哭]。

下面是解决办法:
(需在git base下执行)
中文

英文

2018-03-01后续更新

继昨天修改用户信息后,照常git push…,然后报错w(゚Д゚)w

1
2
3
4
5
6
error: failed to push some refs to 'https://github.com/**/**.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

好,那我就git pull origin gh-pages:gh-pages,结果

1
2
3
4
5
6
remote: Counting objects: 259, done.
remote: Compressing objects: 100% (130/130), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

(。_。) 百度之 第一种解决办法 ,并照做git config –global http.postBuffer 524288000,后又重新pull了一遍,还是报错(生无可恋)。之后各种曲折再不提。
后咨询了一下我的[大神(づ ̄3 ̄)づ╭❤~],甩给我一个链接 第二种解决办法
输入命令如下

1
2
3
# 为 git 添加配置项,通过下面的命令可以简单完成
# 在这之前可以执行 git config -l 命令看看已有配置项有哪些
git config --add core.compression -1

这里又遇到一个坑┑( ̄Д  ̄)┍ ! core.compression -1这个是数字111111,我一开始输了字母l,所以输其他命令的时候给我报错

1
fatal: bad numeric config value '-l' for 'core.compression': invalid unit

重新输了一遍正确的想着把原来的给替换掉,事实证明That’s impossible,遂又输入以下命令(–unset 删除一个配置项),好嘛,接着报错

1
2
3
git config --unset core.compression

warning: core.compression has multiple values

再次输入git config –unset-all core.compression
,终于不报错,再次git config -l查看都删掉了。
遂重新输入一遍git config –add core.compression -1。并再次git pull origin gh-pages:gh-pages,并git push…
俗话说,伤心总是难免的,┭┮﹏┭┮

1
2
3
4
5
error: failed to push some refs to 'https://github.com/**/**.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

奇怪,我刚刚明明已经pull了,为啥还报这种错。重新pull后发现

1
fatal: refusing to merge unrelated histories

又百度,说可以用–allow-unrelated-histories来强制合并。遂输入git pull origin gh-pages –aloow-unrelated-histories,又报错

1
Automatic merge failed; fix conflicts and then commit the result.

git status检查发现有冲突,遂手动解决冲突,再次commits → push。
至此,终于成功,话好啰嗦。。。(๑•̀ㅂ•́)و✧

这都是我没有好好学习git命令的下场,╭(╯^╰)╮