git 出现 error: Your local changes to the following files would be overwritten by merge
程序员文章站
2022-07-13 21:12:35
...
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
```
上一篇: 1 部署
推荐阅读
-
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
-
git pull error: Your local changes to the following files would be overwritten by merge:
-
git merge 报错:error: Your local changes to the following files would be overwritten by m
-
git 删除本地修改 Your local changes to the following files would be overwritten by merge
-
git pull 提示错误,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:
-
Git出现冲突error: Your local changes to the following files would be overwritten by merge
-
git pull报错:error: Your local changes to the following files would be overwritten by merge:
-
git pull 提示错误,Your local changes to the following files would be overwritten by merge