git常见问题解决方式(持续更新)

git常见问题解决方式

问题一:git commit提示fatal: Unable to create index.lock File exists

报错内容:

$ git commit -m 'Test'
fatal: Unable to create 'D:/MyProject/.git/index.lock': File exists.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.

解决方案:

​ 在项目根目录下找到 .git 文件夹。打开该文件夹。找到文件夹里面的index.lock 文件,将其删除,即可解决问题(如果提示不能删除文件,就重启系统)。

表现形式:

​ 提交后更改数为0,修改了文件后点击保存,更改数就会变成无。形成一种脱机现象,文件修改无效,也无法上传。

产生原因:

​ 应该是由于git操作的时候修改了一些文件导致的操作冲突被锁住了。

问题二:git pull提示There is no tracking information for the current branch

报错内容:

git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.

解决方案:

​ 方案一:比如说操作master,在pull时直接指定远程master:

git pull origin master

​ 方案二:比如操作master,可以先在指定本地master到远程master,然后再去pull:

git branch --set-upstream-to-origin/master master
git pull

产生原因:

​ 是因为本地分支和远程分支没有建立联系(使用git branch -vv可以查看本地分支和远程分支的关联关系)。

问题三:git clone提示Filename too long

报错内容:

git clone git@xxxx.git

......
error:unable to create file xxxx : Filename too long
fatal:unable to checkout working tree
warning:Clone succeeded,butcheckout failed
You can inspect what was checked out with ‘git status’ and retry the checkout with ‘git checkout -f HEAD’
......

解决方案:

​ 在git bash中,运行下列命令: git config --global core.longpaths true就可以解决该问题。

​ --global是该参数的使用范围,如果只想对本版本库设置该参数,只要在上述命令中去掉–global即可。

​ 然后在执行 git checkou -f HEAD命令即可继续完成clone远程仓库项目。

git config --global core.longpaths true
git checkou -f HEAD

产生原因:

​ git是可以支持创建4096长度的文件名,上诉问题在Unix系统和Mac系统中是不会出现的,这是在Windows系统中调用旧的api,支持长度260长度的文件名。允许较长的文件名这个设置在Windows系统中默认是关闭的。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值