git 遇到的问题

1、error: RPC failed; curl transfer closed with outstanding read data remaining

解决办法:

git clone https://username@bitbucket.org/repositoryName.git --depth 1

说明:  针对的是有submodule情况,而且--depth=1 表示只下载最近一次的版本,使用浅复制可以大大减少下载的数据量 

2、Trying to git pull with error: cannot open .git/FETCH_HEAD: Permission denied

解决办法:

sudo chmod -R g+w .git

说明: mac环境

3、清空npm缓存

sudo npm cache verify clean

说明:方便下次npm安装依赖

4、解决:Gitlab 的 Permission denied (publickey) 错误

在 .ssh 文件夹目录下config加上

Host gitlab.com
User git
Hostname gitlab.com
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes

说明: mac的~/.ssh目录下

5、Getting permission denied errors when i try to install this module globally with SUDO
解决:

sudo npm install --unsafe-perm=true --allow-root

说明:加权限安装

6、Error: spawn ../node_modules/optipng-bin/vendor/optipng ENOENT

解决:

sudo npm rebuild

说明:安装的npm有时需要rebuild一下才正常

7、FIX warning: ignoring broken ref refs/remotes/origin/HEAD

解决:

1、rm .git/refs/remotes/origin/HEAD

2、git fetch --all

3、git branch -r | grep -v '->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done

【拉取所有远程所有分支】

说明:删掉错误的HEAD,拉取最新的远程分支

 8、Git push error: Unable to unlink old (Permission denied)

解决:

sudo chmod -R ug+w .;

说明:给对应的文件夹加上可以修改的权限

9、Error: Remote HEAD refers to nonexistent ref, unable to checkout

解决:

git branch -a

git checkout new-master

说明:分支指向不明确,那就明确指向 

原文地址:https://www.cnblogs.com/wuyongyu/p/8269398.html