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

3ad1444d^ .. 73e10933 为远程分支新提交,ac-dev分支落后远程分支3ad1444d^ .. 73e10933 个提交。现对ac-dev分支进行了修改,打算将ac-dev分支同步到3ad1444d最新提交,并保留ac-dev分支落后时的修改;

ac-dev落后修改后没有提交或将其隐藏,直接cherry-pick遇到以下错误。

git cherry-pick 3ad1444d^ .. 73e10933
error: Your local changes to the following files would be overwritten by merge:
        Config/AcProject/CMakeLists.txt
        AcProject/AcPhotoSnap.cpp
        Compiler.sh
Please commit your changes or stash them before you merge.
Aborting
fatal: cherry-pick failed

这个错误通常发生在尝试合并(merge)时出现,说明有冲突。对此,git 给出了提示 : 请在合并之前提交更改或将其隐藏。

处理方法:
1. git stash save "ac-dev imu"
2. git checkout master
3. git pull
4. git checkout ac-dev
5. git cherry-pick 3ad1444d^ .. 73e10933
6. git stash pop

    Auto-merging Compiler.sh
    Auto-merging AcProject/AcPhotoSnap.cpp
    CONFLICT (content): Merge conflict in AcProject/AcPhotoSnap.cpp
    Auto-merging Config/AcProject/CMakeLists.txt
    CONFLICT (content): Merge conflict in Config/AcProject/CMakeLists.txt
    The stash entry is kept in case you need it again. (藏匿条目会保留下来,以防您再次需要。)

7. git status
    On branch ac-dev
    Changes to be committed:
      (use "git restore --staged <file>..." to unstage)
            modified:   AcProject/AcPhotoSnap.h

    Unmerged paths:
      (use "git restore --staged <file>..." to unstage)
      (use "git add <file>..." to mark resolution)
            both modified:   Config/AcProject/CMakeLists.txt
            both modified:   AcProject/AcPhotoSnap.cpp

8. 依照 git 提示解决冲突即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值