2016 年 6 月更新: 根据this page:
对 Team Services Git 存储库的 SSH 身份验证目前处于私人预览阶段
如果可以的话,我建议您切换到 SSH 身份验证,因为这样可以完全避免这个问题。 (请注意,您可以同时使用 HTTPS 和 SSH,even on the same machine。)
如果您尚未启用此功能,或者您无法切换到 SSH,请继续阅读。
原帖:
正如@Oxymoron 提到的,问题在于您的存储库太大,或者更具体地说,您试图一次推送太多。
什么?那没有意义!这不是HTTP 404 代码的用途!
这对我来说也没有意义。 *盯着微软的大方向*
你可能已经遇到过这样的错误:
Unable to rewind rpc post data - try increasing http.postBuffer
这很可能是导致您执行您提到的git config 命令的原因。
现在,出于我发布单独答案的目的:我想详细说明如何解决此问题。您仍然会尝试一次推送一组较小的提交,但这并不总是像听起来那么容易。流程如下:
确定一次推送多少次提交。我通常会推荐一个二分搜索来确定你可以推送多少,但这可能很困难,因为推送之间的等待时间。此外,许多 repos 的第一次提交非常大,或者之后的某些提交非常大。如果您知道此类提交,请尝试自行推送。如果你的仓库足够小,一次只推送一个提交可能是最简单的。否则,尝试推送 20-30 次提交,如果遇到问题,请减少数量。
假设你有一个分支master,在同一个地方创建一个新分支,例如master-temp。
将master 重置为您要推送的第一个组中的最后一个提交。例如。 git reset --hard master-temp~100.
推送该提交 (git push)。
在下一组的最后一次提交时进行--ff 合并。 (git merge --ff-only master-temp~90)
重复第 4 步和第 5 步,直到推送所有提交。
例如,考虑这个 repo:
$ git log --oneline --decorate
* fffffff (HEAD -> master) Commit six
* eeeeeee Commit five
* ddddddd Commit four
* ccccccc Commit three
* bbbbbbb Commit two
* aaaaaaa Commit one
这就是你要做的,假设你想一次推送一个提交:
$ git checkout -b master-temp master
$ git checkout master
$ git reset --hard aaaaaaa
$ git push origin master
$ git merge --ff-only bbbbbbb
$ git push origin master
$ git merge --ff-only ccccccc
$ git push origin master
$ git merge --ff-only ddddddd
$ git push origin master
$ git merge --ff-only eeeeeee
$ git push origin master
$ git merge --ff-only fffffff
$ git push origin master
理想情况下,一切正常,您就完成了。但是如果一个给定的提交不能被推送,即使那是你推送的唯一提交,会发生什么?首先,尝试再推一两次;推动失败所需的时间似乎有些不一致。
如果还是不能推送,那就是重写历史的时候了。
但我不想改写我的历史!我的 Git 日志很好而且很干净,因为我花了很多时间学习如何write great commit messages,而且我总是keep my commits atomic。
别担心,完成后您仍会获得原始历史记录。
返回(更新的)示例 repo:
* fffffff (HEAD -> master) Tiny commit five
* eeeeeee Tiny commit four
* ddddddd Tiny commit three
* ccccccc Tiny commit two
* bbbbbbb Tiny commit one
* aaaaaaa This commit is massive
(大规模提交可以在任何地方,也可以有多个。)
一般的想法是,您对split the massive commit into a few smaller ones 进行交互式变基 (git rebase -i)。
$ git checkout -b master-temp master
$ git rebase -i --root
注意:--root 仅在您需要拆分第一个提交时才需要。否则,例如git rebase -i bbbbbbb.
将要拆分的提交从 pick 更改为 edit。
$ git reset HEAD^
$ git add somefiles
$ git commit
$ git push origin master-temp
$ git add someotherfiles
$ git commit
$ git push origin master-temp
$ git rebase --continue
$ git push origin master-temp
现在这就是 magit 魔法发生的地方:
$ git checkout master
switched to branch 'master'
$ git push origin master
POST git-receive-packed (chunked)
remote: Analyzing objects... (1212/1212) (2518523 ms)
remote: Storing packfile... done (48186 ms)
remote: Storing index... done (228 ms)
Pushing to https://example.visualstudio.com/SomeCollection/SomeTeam/_git/MyRepo
To https://example.visualstudio.com/SomeCollection/SomeTeam/_git/MyRepo
* [new branch] master -> master
updating local tracking ref 'refs/remotes/origin/master'
最后一个命令会成功,因为 Git 足够聪明,可以重用您已经推送的项目,即使它们在不同的提交中。 (请注意,Analyzing objects 步骤耗时最长。这是 Git 计算可以重用多少以及需要上传多少。)如果您有兴趣了解有关其工作原理的更多信息,请查看Packfiles section of the Git Internals docs,也许是在刷完Git Objects之后。
我有没有提到 Git 很棒?