解决问题:
问题:vscode 无法查看远程新分支
- 解决:更新远程分支信息
git remote update origin --prune
问题:git add 报 warning: LF will be replaced by CRLF in…
-
解决:我一般用第一种
// 提交时转换为LF,检出时转换为CRLF git config --global core.autocrlf true
// 提交时转换为LF,检出时不转换 git config --global core.autocrlf input
// 提交检出均不转换 git config --global core.autocrlf false
问题: GitLab 线上合并冲突
-
解决:假设自己分支合并到主分支时发生冲突
1. 拉取远程master到本地 git pull origin master 2. 创建并切换到 fix-解决什么页面的冲突 分支 git checkout -b fix-页面名 3. 合并自己的分支 git merge 自己的分支名 4. 在编辑器 VScode 上解决冲突地方,保存查看有无报错 5. 再提交解决冲突的分支 git commit -m "fix:解决页面冲突" 6. 在浏览器中合并分支
问题:使用 GitLab 发送分支合并请求时,出现This merge request already existed(此合并请求已存在)
- 原因:之前的请求合并失败,但请求状态还在。如需再次提交会提示请求已经存在,需要将之前的合并请求关闭后,再发送合并请求。
- 解决:在提交记录中找到之前的合并请求并关闭,再次发送新的合并请求
问题:git每次提交都要输入账号密码
-
第一次使用 git 已经配置了全局参数
git config --global user.name 'name' git config --global user.email 'email'
-
解决:在下次提交时输入账号和密码后,就不需要重复登录了
git config --global credential.helper store
问题:git 提交时报错 error: RPC failed; curl 52 Recv failure: Connection was reset send-pack: unexpected disconnect while reading sideband packet fatal: the remote end hung up unexpectedly Everything up-to-date
-
原因:可能是某个文件过大造成的
-
3种解决方式:
-
将缓存修改为500mb或者更大
$ git config --global http.postBuffer 524288000 // 或者 $ git config --global http.postBuffer 1048576000
-
配置最低速度和最低速度时间
$ git config --global http.lowSpeedLimit 0 $ git config --global http.lowSpeedTime 999999
-
git-lfs 具体用法见官网
$ git lfs install $ git lfs track "*.so" $ git add .gitattributes
-
问题:git提交或克隆报错fatal: unable to access ‘https://github.com/xxx.git/’
- 原因:git在拉取或者提交项目时,中间会有git的http和https代理,但是我们本地环境本身就有SSL协议了,所以取消git的https代理即可,不行再取消http的代理。
- 解决:
//取消http代理 git config --global --unset http.proxy //取消https代理 git config --global --unset https.proxy
问题:git pull报错 error: Your local changes to the following files would be overwritten by merge:
- 原因:本地修改了新代码,没有提交,将会被远程的代码覆盖
- 解决:
- 方式一:保留本地新修改的代码,并下拉远程代码到本地
git stash git pull origin master git stash pop
- 方式二: 不保留本地新修改的代码,并下拉远程代码到本地
git reset --hard git pull origin master
- 方式一:保留本地新修改的代码,并下拉远程代码到本地
问题:git fatal unable to access ‘仓库地址’ could not resolve
- 解决:在 命令行 使用一次你要执行的命令即可