首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >合并文件的git压缩

合并文件的git压缩
EN

Stack Overflow用户
提问于 2013-07-07 05:58:48
回答 1查看 48关注 0票数 1

我的git日志显示了前4个提交。第一个提交是在我尝试推送代码时形成的,它要求我先拉出代码,然后再推送。(基本上是合并了)。

代码语言:javascript
运行
复制
 commit 71c136f44e5bddd358d86277da730229d871f48c
    Merge: d896439 fe59f57
    Author: Ankit Gupta <ankit.gupta8898@gmail.com>
    Date:   Sat Jul 6 21:06:01 2013 +0100

        Merging

    commit d896439d1a33e6c0f3c78f1bf4ad731941c3c0bd
    Author: Ankit Gupta <ankit.gupta8898@gmail.com>
    Date:   Sat Jul 6 21:03:20 2013 +0100

        Message1

    commit fe59f57bec7eb2764c4c4e5cd1f5fdc21001bcc5
    Author: Ankit Gupta <ankit.gupta8898@gmail.com>
    Date:   Sat Jul 6 21:03:20 2013 +0100

        Message 2

    commit caa12dab636587a741ebc97c4e461d1618de55f9
    Author: Ankit Gupta <ankit.gupta8898@gmail.com>
    Date:   Fri Jul 5 16:20:54 2013 +0100

        Message 3

我想将所有这4个提交都压缩到最新的(71c136)中,当我执行git rebase -i HEAD~4时,它会显示我

代码语言:javascript
运行
复制
   pick 56e3419 Message 4
    pick caa12da Message 3
    pick d896439 Message 2
    pick fe59f57 Message 1
# Rebase ebabdfb..71c136f onto ebabdfb
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
#

为什么它没有列出第一个提交,以及如何压缩所有4个提交?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-07 06:57:25

要将所有四个提交合并为一个提交,您可以遵循类似于“git: how to insert a commit as the first, shifting all the others?”中描述的方法:

代码语言:javascript
运行
复制
git symbolic-ref HEAD refs/heads/newroot
git rm --cached -r .
git clean -f -d
# All commits should be listed then: you can squash them
git rebase --interactive --onto newroot --root master
git branch -d newroot
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17507507

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档