git常见的n个报错解决

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值