【转】一次性git revert多条提交

原文:

https://developer.aliyun.com/article/719851

如果用git revert 一个一个revert 挺费劲,可以用git revert OLDER_COMMIT^..NEWER_COMMIT 这种格式

这样会在log 上多留下多条revert相关的记录,如果不想生成revert相关的记录呢?

就是多加个 -n 参数,然后再通过 git add 和git commit 等步骤就可以了。

以下是实操结果。

git log查看记录:

$ git log
commit 03d98f41c...d3fd8d91e
Author: gerrit2 <gerrit2@ttt.com>
Date:   Tue Oct 10 15:40:32 2023 +0800

    Commit label TTT_SDK_V000.2.24.F0017.7

commit d3611426...6f848082b
Author: gerrit2 <gerrit2@ttt.com>
Date:   Mon Sep 25 12:37:26 2023 +0800

    Commit label TTT_SDK_V000.2.24.F0017.6

commit 2bdb4a2c...54aefdc673713
Author: gerrit2 <gerrit2@ttt.com>
Date:   Thu Sep 7 18:41:00 2023 +0800

    Commit label TTT_SDK_V000.2.24.F0017.5

commit f9e6550...1b233
Author: gerrit2 <gerrit2@ttt.com>
Date:   Thu Aug 31 18:39:33 2023 +0800

    Commit label TTT_SDK_V000.2.24.F0017.4

commit 37b7c4...0ab156af
Author: gerrit2 <gerrit2@ttt.com>
Date:   Wed Aug 30 13:57:00 2023 +0800

    Commit label TTT_SDK_V000.2.24.F0017.3

commit dbdaf3...6bfab6a35
Author: gerrit2 <gerrit2@ttt.com>
Date:   Fri Aug 25 18:40:58 2023 +0800

    Commit label TTT_SDK_V000.2.24.F0017.2

commit 25d9aaa2...fb81deb8
Author: gerrit2 <gerrit2@ttt.com>
Date:   Tue Aug 22 15:51:31 2023 +0800

    Commit label TTT_SDK_V000.2.24.F0017.1

commit 461e5...109e9c49
Author: gerrit2 <gerrit2@ttt.com>
Date:   Fri Mar 3 18:16:50 2023 +0800

git revert -n:

$ git revert -n 25d9aaxxx1deb8^..03d98xxxd91e

git commit -m:

$ git commit -m "revert for test"

git push gerrit:

$ git push gerrit HEAD:refs/for/branch_name%topic=mem_test

 

posted @ 2023-10-13 09:31  xiululu  阅读(613)  评论(0编辑  收藏  举报