git提交失败总结

在用Git管理代码版本时,用git push命令提交代码,提示:

【错误1】

错误原因:后来发现是提交大文件导致http postbuffer溢出,将postbuffer改大就可以了

解决办法:git config http.postBuffer 524288000

【错误2】

   

    有以下几个可能性:

  1. Git 版本过低。GitCafe 推荐使用的 Git 版本是 >= 1.7。

    $ git --version

  2. 远程仓库路径设置错误。注意,Git 对于路径的识别是大小写敏感的。

    查看已有的远程仓库:

    $ git remote -v
    origin  https://gitcafe.com/xxx/help.git (fetch)
    origin  https://gitcafe.com/xxx/help.git (push)
    

    设置新的远程仓库路径:

    $ git remote set-url origin https://gitcafe.com/xxx/Help.git
    

    查看新的远程仓库路径:

    $ git remote -v
    origin  https://gitcafe.com/xxx/Help.git (fetch)
    origin  https://gitcafe.com/xxx/Help.git (push)
    
  3. 对该仓库没有访问权限。检查你是否对目标仓库有相应的读写权限。

  4. 输入了错误的用户名和密码。检查你是否使用了对该仓库有写权限的正确的账户名称和密码,检查是否对所有你名下的仓库均不能访问。

(以上内容部分转自:https://gitcafe.com/GitCafe/Help/wiki/%E5%A6%82%E4%BD%95%E5%BA%94%E5%AF%B9-Git-%E6%93%8D%E4%BD%9C%E6%97%B6%E5%80%99%E7%9A%84-HTTP-%E9%94%99%E8%AF%AF,如有不当,请联系我删除)

 
【错误3】

Git Your branch is ahead of 'origin/master' by X commits解决方法

(1)方法1:git fetch origin

(2)方法2(代码还需要):git push origin

(3)方法3 (代码不需要):git reset --hard origin/$branch

  参考:

  https://blog.csdn.net/Thousa_Ho/article/details/73350703

  https://stackoverflow.com/questions/16288176/your-branch-is-ahead-of-origin-master-by-3-commits

  可以先执行下git  diff $branch origin/$branch 看下差异

【备注,先git log 看看还有没有没有push 的commit的,如果没有,就用git reset --hard origin/$branch强制覆盖成和远程仓库一样,如果有的话,就先push】

(4) git pull --rebase

(5)git pull origin cherryPick

  参考:https://blog.csdn.net/u010383937/article/details/72901675

原文地址:https://www.cnblogs.com/tibetanmastiff/p/11866578.html