This article describes how to use Git-AM and format-patch. Because in git usage, Many times someone else (supplier or other developers) sends a series of patches. These patches are usually named like this: 0001--JFFS2-community-fix-with-not-use-OOB.patch0002--Community-patch-for-Fix-mount-error-in.patch0003--partial-low-interrupt-latency-mode-for-ARM113.patch0004--for-the-global-I-cache-invalidation-ARM11.patch0005--1-arm-Add-more-cache-memory-types-macr.patch0006--2-Port-imx-3.3.0-release-to-2.6.28.patch0007--3-Add-MX25-support.patch0008--Move-asm-arch-headers-to-linux-inc-dir.patch0009--1-regulator-allow-search-by-regulator.patch It contains submitted logs, authors, dates, and other information. What you want to do is introduce these patches to your In the code library, it is best to introduce logs for future maintenance. The traditional patch method is patch -p1 < 0001--JFFS2-community-fix-with-not-use-OOB.patch In this way, patch is used, but the useful information will be lost. Because these patches are obviously generated using git format-Patch, you should be able to do well with the GIT tool. Git-am is used to do this. Before using Git-Am, you must first use git am-Abort once to discard the previous am information so that you can perform a new AM. Otherwise, you will encounter such an error.
.git/rebase-apply still exists but mbox given. Git-am can merge a file at a time, all the patches in a directory, or patches in your mailbox directory. The following are two examples:
- You now have a code base: Small-Src. Put your patch file in ~ /Patch/0001-trival-patch.patch
cd small-srcgit-am ~/patch/0001-trival-patch.patch If the patch is successful, you can have a cup of tea. If it fails, git will prompt an error, for example: error: patch failed: android/mediascanner.cpp:452error: android/mediascanner.cpp: patch does not apply In this way, you need to first look at the patch, and then modify the wrong file so that the patch can be patched.
- You have a bunch of patches named the ones mentioned above. You put them in ~ /Patch-set/directory (random path)
cd opencoregit am ~/patch-set/*.patch (Here, git will execute these patches in the order of file names) If everything goes well, all your patches are OK, and you are lucky again. However, if a patch is encountered in git am, am will stop hitting this The patch location tells you which patch cannot be mounted. For example, I have a file and two patches. The file content is the textmore text The two patches are: 0001-add-line.patch: From 48869ccbced494e05738090afa5a54f2a261df0f Mon Sep 17 00:00:00 2001From: zhangjiejing <zhangjiejing@zhangjiejing-desktop.(none)>Date: Thu, 22 Apr 2010 13:04:34 +0800Subject: [PATCH 1/2] add line--- file | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)diff --git a/file b/fileindex 067780e..685f0fa 100644--- a/file+++ b/file@@ -3,3 +3,5 @@ file: some text more text++add line--1.6.3.3 0002-change-line.patch: From f756e1b3a87c216b7e0afea9d15badd033171578 Mon Sep 17 00:00:00 2001From: zhangjiejing <zhangjiejing@zhangjiejing-desktop.(none)>Date: Thu, 22 Apr 2010 13:05:19 +0800Subject: [PATCH 2/2] change line--- file | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)diff --git a/file b/fileindex 685f0fa..7af7852 100644--- a/file+++ b/file@@ -1,6 +1,6 @@ file:-some text+Change line text more text--1.6.3.3 Run Git am *. Patch In the merge patch, an error is reported. patch failed at 0001 add line. So we can see that Patch, the original patch requires some text, and the file contains the text, so we use The editor changes this line to some text, vi filegit apply 0001-add-line.patchgit add filegit am --resolved After resolving the conflict, for example, use git add to let git know that you have resolved the conflict.
- If you find that this conflict cannot be resolved, You need to undo the entire am thing. You can run git am-abort,
- If you want to ignore this patch, you can run git am-Skip to skip this patch.
Git format-patch experience A Git log Commit C Commit B Commit Commit init B Git log Commit init ================== The code for both A and B is commit init. Now a changes to a => B => C B. Want to upgrade with patches A: Git format-Patch Init. c ==> generate three patches 001-commit-a.patch is upgraded from commit init to 002-commit-b.patch is upgraded from commit A to B 003-commit-c.patch is upgraded from commit B to C Git format-patch x .. y From X to Y. (X, Y] ======================== B Git am *. Patch git is automatically upgraded by file name level |