Merge feature points to multiple branches with git patch

 

It is often encountered that the same changes need to be made on the branch and the trunk at the same time, and the patching method can be used.

One way is to use git format-patch

1. After modifying a branch, submit it and get the submit number, such as ab68d50e804b9b31c831a203fae2f0693f29930d

2. git format-patch -M -C ab68d50e804b9b31c831a203fae2f0693f29930d~1..ab68d50e804b9b31c831a203fae2f0693f29930d

Represents a range, ~1 represents the previous commit

3. The above step will generate a 0001-.patch file (the file name may be different)

4. Switch to another branch, git am 0001-.patch (failed)

5. Just use git apply 0001-.patch, you also need to commit and push yourself

 

I failed to apply the .patch file to the branch, so I used another method

1. After modifying a branch, do not submit it yet, use git diff > abc.patch to generate a diff file

2. Switch to another branch after committing to the current branch

3. git apply abc.patch

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327058461&siteId=291194637