git常见的n个报错解决
n.1 error: Your local changes to the following files would be overwritten by merge: protected/config/main.php Please, commit your changes or stash them before you can merge
原因:
代码库文件覆盖本地文件
解决:
代码库文件覆盖本地文件,在别处备份好本地修改之后,丢弃本地修改,再拉取代码。
git reset --hard
git pull
n.2 error: The following untracked working tree files would be overwritten by checkout:
原因:
切换分支当前分支存在修改的文件
解决:
git clean -d -fx “”
其中
x -----删除忽略文件已经对git来说不识别的文件
d -----删除未被添加到git的路径中的文件
f -----强制运行
n.3 fatal: refusing to merge unrelated histories
原因:
本地库和远程库提交了不同的东西,不能正常合并
解决:
git pull origin master --allow-unrelated-histories
n.4 Please enter a commit message to explain why this merge is necessary;
原因:
提交一些文件,需要写入提交原因
解决:
1.按键盘字母 i 进入insert模式
2.修改最上面那行黄色合并信息,可以不修改
3.按键盘左上角"Esc"
4.输入":wq",注意是冒号+wq,按回车键即可
n.5 Your branch is ahead of ‘origin/branch_name’ by 1 commits.Your branch is…
原因:
你的本地修改比代码库多1个提交
解决:
如果需要保留这些提交:git push origin
如果不需要保留这些提交:git reset --hard origin/branch_name