项目过大导致git clone失败解决方案 :
::只会克隆指定分支的最新一条提交
git clone [gitAddress] -b [gitBranch] --depth 1
::-b是指定分支
执行此命令操作clone会很快 ,因为只clone了一个分支和一个commit。 但也会带来2个问题
问题一: 切换不到 历史commit :
解决方法 : 依次执行以下命令
git fetch --depth 10
git fetch --depth 20
git fetch --depth 30
git fetch --depth 40
git fetch --depth 50
git fetch --depth 200
git fetch --depth 210
git fetch --depth 220
git fetch --unshallow
git fetch 替换成 git pull操作也可以。
问题二: 切换不到 别的分支 :
先cmd查看 git config remote.origin.fetch
打印是不是只有当前分支
- 如果打印是
+refs/heads/*:refs/remotes/origin/*
就可以切换所有分支了 - 如果打印是
+refs/heads/branchName:refs/remotes/origin/branchName
就只能查看当前分支 。我们需要全部分支执行以下即可:
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
::再执行以下就会拉取全部分支的 commit
git fetch
::或者
git pull
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git config -l
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
git fetch --depth 1
git fetch --depth 10
git fetch --depth 20
git fetch --depth 40
git fetch --depth 80
git fetch --depth 160
git fetch --depth 320
git fetch --depth 640
git fetch --depth 1280
git fetch --unshallow