Rebase Practice of GIT

Merge unreasonable Commit s with Rebase

View submissions that need to be merged

git log --pretty=oneline

a53ddc61dad65c74cf0b5e6026393a76a475e8e8 (HEAD -> bet-activiey-rebase) modify ignore
c3fc493086fc2afe437a1eb683fefd613df8f147 (origin/bet-activity, bet-activity) Handle orderNo by""Situation
2c058020d9cde54af67df66fe866fcbcff4b5ec9 Processing Tencent Return Time
7e8d555c22c897647fb1afd93fe3a57f04af0f65 Modify time resolution
6a2de6f6dca496297a8d40cbd2e9674146f93945 Replacement time calculation method
2c504089f7c63c9c1e0459e2b2b3a5bbf27c6a46 checkstyle
3e542678da40cd2961617c3213bfd7f3744bc604 Dealing with Payment Time
d996da46eb01f3c139b3e201d8b6d07b4d37780d Dealing with duplicate order numbers
d79017c1f7406f6f14e35ce609827314465e6946 Add a log to view payment status
b034f66dcc8f1db3d01419eae4cc465cee4c9761 Optimizing code
614bc7eb10853988f8f0def3d33caa183d08da94 Modification and Analysis of Tencent Return returnMsg Not necessarily
62714e9f63380885d1fcf9ea5bf0e3456528b015 Modify Path
a96972e443979e7c12a28e50f22feef356159974 Modify Path
7aa73908e4053d75144dda3ffd1db991e697173f Modify Path
bc3bc15e56245f0793c7bbe3cb18d9f0908f0967 Modify Path
4d142e9dabc8daa6eb6f051fc6473e59dfe394b1 checkstyle
579ed59894d2848357d0911ddb29971eef4888a5 checkstyle
6e5a444309a1fab4a65fc242a2f343ba7bc78891 Renewal jooq
3b5e01c61b3f3c8a6637b6dc9d88aa99e4991bde Fixed case and case problems:Delete pre-existing files
58d9c7b912c6aa0a9be0c3e431a7d80bce9aa7b8 Fixed case and case problems
1fb03d8fdadbd52773a3f2cb1f7ddeba7c7a9acb modify GIT Ignore file name case
5a9d94e5e401c97d7f23d8826716f03aab425222 Wechat Payment Improvement and Enterprise Payment Query Interface
f1d85ef4d3d6c47663d847b67cae5455eaf4cf20 (origin/develop, origin/HEAD, develop) Revert

First step, we can merge all the way to f1d85ef4d3d6c47663d847b67cae5455eaf4cf20

We first merged the first six, to 3e542678da40cd29617c3213bfd7f3744bc604

git rebase -i 3e5426

Available options are
    -v, --verbose         display a diffstat of what changed upstream
    -q, --quiet           be quiet. implies --no-stat
pick 2c50408 checkstyle
pick 6a2de6f Replacement time calculation method
pick 7e8d555 Modify time resolution
pick 2c05802 Processing Tencent Return Time
pick c3fc493 Handle orderNo by""Situation
pick a53ddc6 modify ignore

# Rebase 3e54267..a53ddc6 onto 3e54267 (6 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# .       create a merge commit using the original merge commit's
# .       message (or the oneline, if no original merge commit was
# .       specified). Use -c <commit> to reword the commit message.
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
#       However, if you remove everything, the rebase will be aborted.
#
#
# Note that empty commits are commented out

wq is used to save after confirmation, and then a modified page pops up if commit message needs to be modified.

Common commands:

operation Meaning
pick Use the current commit
reword Use the current commit, but modify the commit message
edit With the current commit,rebase pauses, allowing you to modify the commit
squash Using the current commit, the current commit is merged with the previous commit
fixup The effect is the same as square, but the commit message is not maintained.
drop Abandon the current commit

View the merged situation

b9e4e4edd63e86344194dc4809f7e42e0c708f2b (HEAD -> bet-activiey-rebase) Change time in some ways, checkstyle
3e542678da40cd2961617c3213bfd7f3744bc604 Dealing with Payment Time
d996da46eb01f3c139b3e201d8b6d07b4d37780d Dealing with duplicate order numbers
d79017c1f7406f6f14e35ce609827314465e6946 Add a log to view payment status
b034f66dcc8f1db3d01419eae4cc465cee4c9761 Optimizing code
614bc7eb10853988f8f0def3d33caa183d08da94 Modification and Analysis of Tencent Return returnMsg Not necessarily
62714e9f63380885d1fcf9ea5bf0e3456528b015 Modify Path
a96972e443979e7c12a28e50f22feef356159974 Modify Path
7aa73908e4053d75144dda3ffd1db991e697173f Modify Path
bc3bc15e56245f0793c7bbe3cb18d9f0908f0967 Modify Path
4d142e9dabc8daa6eb6f051fc6473e59dfe394b1 checkstyle
579ed59894d2848357d0911ddb29971eef4888a5 checkstyle
6e5a444309a1fab4a65fc242a2f343ba7bc78891 Renewal jooq
3b5e01c61b3f3c8a6637b6dc9d88aa99e4991bde Fixed case and case problems:Delete pre-existing files
58d9c7b912c6aa0a9be0c3e431a7d80bce9aa7b8 Fixed case and case problems
1fb03d8fdadbd52773a3f2cb1f7ddeba7c7a9acb modify GIT Ignore file name case
5a9d94e5e401c97d7f23d8826716f03aab425222 Wechat Payment Improvement and Enterprise Payment Query Interface
f1d85ef4d3d6c47663d847b67cae5455eaf4cf20 (origin/develop, origin/HEAD, develop)

You can see that the first couple merged into the first one.

  1. Merge the submissions of several of the same descriptions in the middle
d79017c1f7406f6f14e35ce609827314465e6946 Add a log to view payment status
b034f66dcc8f1db3d01419eae4cc465cee4c9761 Optimizing code
614bc7eb10853988f8f0def3d33caa183d08da94 Modification and Analysis of Tencent Return returnMsg Not necessarily
62714e9f63380885d1fcf9ea5bf0e3456528b015 Modify Path
a96972e443979e7c12a28e50f22feef356159974 Modify Path
7aa73908e4053d75144dda3ffd1db991e697173f Modify Path
bc3bc15e56245f0793c7bbe3cb18d9f0908f0967 Modify Path
4d142e9dabc8daa6eb6f051fc6473e59dfe394b1 checkstyle
579ed59894d2848357d0911ddb29971eef4888a5 checkstyle

git rebase -i 6e5a444309a1fab4a65fc242a2f343ba7bc78891

This time we want to keep the first few submissions, then merge the above submissions, edited documents.

r 579ed59 checkstyle
s 4d142e9 checkstyle
s bc3bc15 Modify Path
s 7aa7390 Modify Path
s a96972e Modify Path
s 62714e9 Modify Path
s 614bc7e Modification and Analysis of Tencent Return returnMsg Not necessarily
s b034f66 Optimizing code
s d79017c Add a log to view payment status
pick d996da4 Dealing with duplicate order numbers
pick 3e54267 Dealing with Payment Time
pick b9e4e4e Change time in some ways, checkstyle

If you use squash to merge code in a file, you will merge message

# This is a combination of 9 commits.
# This is the 1st commit message:

Adjust the path, optimize the code

# This is the commit message #1:

checkstyle

# This is the commit message #2:

Modify Path

# This is the commit message #3:

Modify Path

# This is the commit message #4:

Modify Path

# This is the commit message #5:

Modify Path

# This is the commit message #6:

Modifying and Resolving Tencent's Return Msg Is Not a Necessary Value

# This is the commit message #7:

Optimizing code

# This is the commit message #8:

Add a log to view payment status

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date:      Mon Jul 15 16:06:28 2019 +0800
#
# interactive rebase in progress; onto 6e5a444
# Last commands done (9 commands done):

Here we use the # operation to indicate ignoring a commit message

Submit after modification, open log

58a752e06fb164960448d3e1383cd1f7c35f1762 (HEAD -> bet-activiey-rebase) Change time in some ways, checkstyle
54bac4f74809688b2a2ccae91aa4dfb68def5b17 Dealing with Payment Time
1c873bbf933df5f42268e85e5dae914aa747c064 Dealing with duplicate order numbers
d1c0883ed015a2655859564cc9ab69bf77a292ad Adjust the path, optimize the code
6e5a444309a1fab4a65fc242a2f343ba7bc78891 Renewal jooq
3b5e01c61b3f3c8a6637b6dc9d88aa99e4991bde Fixed case and case problems:Delete pre-existing files
58d9c7b912c6aa0a9be0c3e431a7d80bce9aa7b8 Fixed case and case problems
1fb03d8fdadbd52773a3f2cb1f7ddeba7c7a9acb modify GIT Ignore file name case
5a9d94e5e401c97d7f23d8826716f03aab425222 Wechat Payment Improvement and Enterprise Payment Query Interface
f1d85ef4d3d6c47663d847b67cae5455eaf4cf20 (origin/develop, origin/HEAD, develop) Revert "Add to Get Tencent Universal accessToken"

It's a lot cleaner than it was at the beginning.

Another way to merge 54bac4 and 1c873b

git rebase --onto d1c0883 54bac4f bet-activiey-rebase

First, rewinding head to replay your work on top of it...
Applying: Change time in some ways, checkstyle
Using index info to reconstruct a base tree...
M	src/main/java/com/xingren/services/weixin/facade/WeixinPayFacade.java
Falling back to patching base and 3-way merge...
Auto-merging src/main/java/com/xingren/services/weixin/facade/WeixinPayFacade.java
CONFLICT (content): Merge conflict in src/main/java/com/xingren/services/weixin/facade/WeixinPayFacade.java
error: Failed to merge in the changes.
Patch failed at 0001 Change time in some ways, checkstyle
Use 'git am --show-current-patch' to see the failed patch

Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".

Post-conflict resolution** git add <filename>**

$ git rebase --continue
Applying: Change time in some ways, checkstyle

git rebase-onto is more than that. You can see the help document in detail and write a blog if you have the chance to use it.

Be careful:

  1. If there is a conflict that needs to be resolved, add the modified file to the temporary area using the GIT add < filename > command, and then use git rebase --continue to rebase
  2. If you encounter problems, you can use git rebase --abort to discard the current rebase

Special statement:

In case of indecision, use git rebase--help

My personal blog. Come and sit down when you have time.

Tags: git Java REST shell

Posted on Mon, 26 Aug 2019 22:28:01 -0700 by misseether