Git常见问题汇总

问题:Your branch is ahead of ‘origin/master’ by 1 commit

原因:你的本地分支高于远程仓库一次提交, 同步更新下,执行命令:

git push origin master

问题:warning: LF will be replaced by CRLF in main.lua The file will have its original line endings in your working directory.

原因:CR代表回车(\r) LF代表换行(\n),在Dos\Windows平台下使用 CRLF 结束一行,即\r\n ;

在Max\Linux平台下是用 LF 结束一行,即\n

如果Mac和Windows平台下代码的更新以及提交,就会出现问题,其解决方式

// 检出时将LF转换为CRLF, 提交时将CRLF转换为LF(windows推荐)
$ git config --global core.autocrlf true
// 提交时转换为LF,检出时不转换(Unix推荐)
$ git config --global core.autocrlf input
// 提交检出均不转换(没有跨平台那一说)
$ git config --global core.autocrlf false

问题:RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 fatal: The remote end hung up unexpecteWriting objectdlys: 62

原因:上传文件有大小限制, 解决方式:

git config http.sslVerify "false"

问题:Your branch and ‘origin/master’ have diverged,and have 1 and 1 different commits each, respectively.

原因:存在两种或多种提交,导致本地与远程不同步。比如远程进行了修改提交,本地在未同步更新的情况下也进行了提交, 解决方式:

git rebase origin/master
git pull --rebase

问题:error: pathspec ‘branch_nameXXX’ did not match any file(s) known to git.

原因:使用其他设备从GitHub中导出远程分支项目,无法成功。其原因在于本地中根本没有其分支。解决命令如下:

-- 获取所有分支的更新
git fetch             
-- 查看本地和远程分支列表,remotes开头的均为远程分支
git branch -a         
-- 导出其远程分支,并通过-b设定本地分支跟踪远程分支
git checkout remotes/branch_name -b branch_name

问题:Your branch is based on ‘origin/branchXXX’, but the upstream is gone

原因:从远程分支拉下代码,在本地创建分支abranch。后又在aBranch的基础上创建分支bBranch,并删除aBranch关联的远程分支。使用git status的时候就会出现该问题,是因为即使你的远程分支删除了,但是分支的关联依然存在。

-- 设置新的关联分支
git branch --set-upstream-to=origin/bBranch

问题:error:unable to delete “branch_NameXXX”: remote ref does not exist

原因:使用git fetch后,然后使用git branch -av 查看本地所有的分支目录,然后删除指定的远程分支(该分支已经不存在了),就会出现该问题, 主要原因是git fetch保存到本地的缓存信息而已,因此可以使用命令:

git fetch --prune origin
或者
git fetch --p origin

问题:将主干合并到个人分支后, 出现无法重置的文件,一般在res中出现类似提示: Encountered 2 file(s) that should have been pointers, but weren’t…

原因:在与git-lfs文件坏掉, 命令:

git rm .gitattributes
git reset --hard HEAD

如果没有生效, 关掉sourceTree重复运行

问题:大文件无法上传, 日志类似如下:

info: Uploading failed due to unsupported Content-Type header(s).
info: Consider disabling Content-Type detection with:
info:
info: $ git config lfs.contenttype false

解决:

-- res目录执行命令, 然后重新push即可
git config lfs.contenttype false
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

鹤九日

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值