IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发工具 -> git am冲突解决办法 -> 正文阅读

[开发工具]git am冲突解决办法

0. 前言

我们在合并patch的时候,希望将patch 作者的基本信息也一并合并,这样就需要git am命令,但是在git am 合并的时候会出现冲突,如何快速有效的解决呢?本文基于git am 命令提供两种方法。

1. 使用git am 命令尝试合并

???????

?

2.?git apply --reject合入不冲突部分,保留冲突部分

git apply --reject 0001-62412e5b8c33ee711aa20500cb1a9bb948c1f7d7.patch
Checking patch mm/page_alloc.c...
warning: mm/page_alloc.c has type 100755, expected 100644
error: while searching for:
                                        const struct alloc_context *ac)
{
        unsigned int noreclaim_flag;
        unsigned long pflags, progress;

        cond_resched();

        /* We now go into synchronous reclaim */
        cpuset_memory_pressure_bump();
        psi_memstall_enter(&pflags);
        fs_reclaim_acquire(gfp_mask);
        noreclaim_flag = memalloc_noreclaim_save();


error: patch failed: mm/page_alloc.c:4476
Hunk #2 succeeded at 4254 (offset -236 lines).
Hunk #3 succeeded at 4267 (offset -236 lines).
Hunk #4 succeeded at 4289 (offset -236 lines).
Applying patch mm/page_alloc.c with 1 reject...
Rejected hunk #1.
Hunk #2 applied cleanly.
Hunk #3 applied cleanly.
Hunk #4 applied cleanly.

3. git status 查看apply 之后的状态

git apply --reject 0001-62412e5b8c33ee711aa20500cb1a9bb948c1f7d7.patch
Checking patch mm/page_alloc.c...
warning: mm/page_alloc.c has type 100755, expected 100644
error: while searching for:
                                        const struct alloc_context *ac)
{
        unsigned int noreclaim_flag;
        unsigned long pflags, progress;

        cond_resched();

        /* We now go into synchronous reclaim */
        cpuset_memory_pressure_bump();
        psi_memstall_enter(&pflags);
        fs_reclaim_acquire(gfp_mask);
        noreclaim_flag = memalloc_noreclaim_save();


error: patch failed: mm/page_alloc.c:4476
Hunk #2 succeeded at 4254 (offset -236 lines).
Hunk #3 succeeded at 4267 (offset -236 lines).
Hunk #4 succeeded at 4289 (offset -236 lines).
Applying patch mm/page_alloc.c with 1 reject...
Rejected hunk #1.
Hunk #2 applied cleanly.
Hunk #3 applied cleanly.
Hunk #4 applied cleanly.
~/work/jr510_r_1.0_dev/android/kernel/jlq-5.4:
git status .
HEAD detached at f315c6d67d28
You are in the middle of an am session.
  (fix conflicts and then run "git am --continue")
  (use "git am --skip" to skip this patch)
  (use "git am --abort" to restore the original branch)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   mm/page_alloc.c

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        mm/page_alloc.c.rej

会在文件目录下产生一个 .rej 后缀的文件,里面就是无法自动合并的冲突,需要手动修改。

4. git am --continue 进行中断后的操作

  • 因为修改后的文件是modified 状态,需要git add 将其修改位added 状态,然后进行
  • git am --continue 进行之前中断后的操作。
  • 有可能需要Changed Id,git commit --amend 可以生成;
  • git log 查看是否已经添加成功;
  • git show 查看patch 是否是自己需要的;

5. 第二种方法

  • 对于修改起来比较简单的,可以手动修改之后产生一个修改的manual.patch;
  • 然后同样git am source.patch,这个时候会提示冲突;
  • 不要管上面这一步,直接git apply manual.patch,这个patch 肯定可以apply的;
  • git add -> git am --continue -> git commit --amend -> git push。。

  开发工具 最新文章
Postman接口测试之Mock快速入门
ASCII码空格替换查表_最全ASCII码对照表0-2
如何使用 ssh 建立 socks 代理
Typora配合PicGo阿里云图床配置
SoapUI、Jmeter、Postman三种接口测试工具的
github用相对路径显示图片_GitHub 中 readm
Windows编译g2o及其g2o viewer
解决jupyter notebook无法连接/ jupyter连接
Git恢复到之前版本
VScode常用快捷键
上一篇文章      下一篇文章      查看所有文章
加:2022-07-03 11:02:22  更:2022-07-03 11:03:00 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/5 22:14:03-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码