git 合并多个commit

假如现在要合并b943f045a9af 和 8380ce479010 这两个commit

tiantao@EstBuildSvr1:~/kernel/rebasekernel/kernel$ git log --oneline
b943f045a9af (HEAD) mm/sparse: fix kernel crash with pfn_section_valid check
8380ce479010 mm: fork: fix kernel_stack memcg stats for various stack implementations
726b7bbeafd4 hugetlb_cgroup: fix illegal access to memory

执行tiantao@EstBuildSvr1:~/kernel/kernel$ git rebase -i 726b7bbeafd4 ,注意这里一定要rebase 到要合并的前一个
pick 8380ce479010 mm: fork: fix kernel_stack memcg stats for various stack implementations
pick b943f045a9af mm/sparse: fix kernel crash with pfn_section_valid check

# Rebase 726b7bbeafd4..b943f045a9af onto 726b7bbeafd4 (2 commands)

将第二个pick 改成s,

pick 8380ce479010 mm: fork: fix kernel_stack memcg stats for various stack implementations
s b943f045a9af mm/sparse: fix kernel crash with pfn_section_valid check

# Rebase 726b7bbeafd4..b943f045a9af onto 726b7bbeafd4 (2 commands)
#

就会看到下面的log,将两个commit message 也合并了
# This is a combination of 2 commits.
# This is the 1st commit message:

mm: fork: fix kernel_stack memcg stats for various stack implementations

Depending on CONFIG_VMAP_STACK and the THREAD_SIZE / PAGE_SIZE ratio the
space for task stacks can be allocated using __vmalloc_node_range(),
alloc_pages_node() and kmem_cache_alloc_node().

In the first and the second cases page->mem_cgroup pointer is set, but
in the third it's not: memcg membership of a slab page should be
determined using the memcg_from_slab_page() function, which looks at
page->slab_cache->memcg_params.memcg .  In this case, using
mod_memcg_page_state() (as in account_kernel_stack()) is incorrect:
page->mem_cgroup pointer is NULL even for pages charged to a non-root
memory cgroup.

It can lead to kernel_stack per-memcg counters permanently showing 0 on
some architectures (depending on the configuration).


# This is the commit message #2:

我一般不改commit message,这样容易知道哪连个commit 被合并了,这里为了demo改成this is a test
this is a test
# Please ente

最后结果,可以看到这两个commit 已经被合并成一个,commit log 被改成this is a test
tiantao@EstBuildSvr1:~/kernel/rebasekernel/kernel$ git rebase -i 726b7bbeafd4
[detached HEAD 916cacc54138] this is a test
 Author: Roman Gushchin <[email protected]>
 Date: Sat Mar 28 19:17:25 2020 -0700
 4 files changed, 58 insertions(+), 2 deletions(-)
Successfully rebased and updated detached HEAD.
tiantao@EstBuildSvr1:~/kernel/rebasekernel/kernel$ git log --oneline
916cacc54138 (HEAD) this is a test
726b7bbeafd4 hugetlb_cgroup: fix illegal access to memory
发布了1444 篇原创文章 · 获赞 67 · 访问量 140万+

猜你喜欢

转载自blog.csdn.net/tiantao2012/article/details/105447600