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代表回车( ) LF代表换行( ) ,在DosWindows平台下使用 CRLF 结束一行,即 ; 在MaxLinux平台下是用 LF 结束一行,即  

如果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
 更多参考: https://www.jianshu.com/p/450cd21b36a4

error: 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

 

最后执行命令:

git push origin master

error: pathspec 'branch_fistfight_0802' did not match any file(s) known to git.

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

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

Your branch is based on 'origin/****', but the upstream is gone

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

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

error:unable to delete "branch_Screen_0705": remote ref does not exist

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

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

令:

原文地址:https://www.cnblogs.com/SkyflyBird/p/10726600.html