git 出现 error: Your local changes to the following files would be overwritten by merge

git 出现 error: Your local changes to the following files would be overwritten by merge

1. 软件描述

git :git version 2.26.2.windows.1

2. 出现问题

```shell
error: Your local changes to the following files would be overwritten by merge:
		frontend/finance/views.py
Please commit your changes or stash them before you merge.
Aborting

```

3. 问题描述

1. 与朋友同时工作写代码,项目代码中有个a.php文件
2. 朋友发现a.php第50行有一个bug,进行更改了。
3. 一会我又发现a.php第100行还有一个问题,我也改了文件a.php
4. 朋友提交了问题a.php 执行步骤如下
```shell
    先更新
    git pull
	再提交
	git add a.php
	git commit -m "修改第50行的bug"
```

5. 经理过来了,说这个项目中b.php还有一个bug,让我修改一下,于是我又修改了b.php
6. 修改完毕,我准备提交

```shell
    先更新
    git pull(此处更新失败)
	提示:
	error: Your local changes to the following files would be overwritten by merge:
			frontend/finance/views.py
	Please commit your changes or stash them before you merge.
	Aborting

	说明有冲突,那我解决冲突,先把自己的文件提交
	git add a.php
	git commit -m "修改第50行的bug"
	我再更新,还是有问题。
	git pull 
```

4. 解决方法

1. 如果只执行到第4步骤,只更改了a.php其他没动,我就提交再更新一点问题没有,
	```shell
git add a.php
git commit -m '修改a.php b.php'
git pull
git push

```
2. 但是走到第6步骤,就有问题了,因为我还修改了b.php 这个时候需要把所有更改的文件添加,解决如下:
```shell
git add a.php b.php 
git commit -m '修改a.php b.php'
git pull
git push

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值