1.git fatal: not a git repository (or any of the parent directories): .git
原因:需要进入 .git 所在目录再执行命令
或者:执行git init
2.git: ‘add.’ is not a git command. See ‘git --help’.
原因:add . 后面需带一个空格
解决:git add .
3. fatal: ‘origin’ does not appear to be a git repository fatal: Could not read from remote repository.
原因:可能和远程仓库连接断开了
解决:查看远程仓库连接信息,看不到就是断开了
git remote –v
重新添加远程仓库
git remote add origin 仓库地址
检查分支是否正确
git branch -v
4. error: failed to push some refs to ‘XXX’
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.
原因:本地代码和远程代码冲突
解决:git pull --rebase origin master
5. Filename too long
原因:文件名太长了
解决:git config core.longpaths true
本文详细解释了Git中常见的五种错误,包括目录结构问题、命令使用误区、远程仓库连接、代码合并冲突以及文件路径过长,提供了相应的解决方法和提示。
3万+

被折叠的 条评论
为什么被折叠?



