我们在合并patch的时候,希望将patch 作者的基本信息也一并合并,这样就需要git am命令,但是在git am 合并的时候会出现冲突,如何快速有效的解决呢?本文基于git am 命令提供两种方法。
- 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.
- 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 后缀的文件,里面就是无法自动合并的冲突,需要手动修改。