git:压扁/修复先前的提交 [英] git: squash/fixup earlier commit
问题描述
假设您有:
ABC
现在您的构建/测试失败。修复应该合并在A.
中我目前的工作流程如下所示:
$ git commit -m fixA
ABC-fixA
$ git rebase -i A〜1
和A中的squash fixA,导致:
$ b $ pre $ A'-BC
是否有命令执行类似操作:
ABC +(带A的修正索引)
$ git commit -supperdupper A
结果:
A'-BC
如果您只是寻找修复早期提交的简单解决方案,题!它解释了一切。但是,由于Elmarco需要一个流畅的方式,所以我们来看看:
从Git 1.7.0开始,有一个 - -autosquash
选项用于 rebase
,它可以做你想做的。还有 - fixup
和 - squash
选项用于 commit
让事情变得更简单。有了别名,你甚至可以把整件事情变成一个单一的命令。
我建议升级到最新的Git以获得最大的可怕度:
git / Documentation / RelNotes $ grep -i -A1 autosquash\\\ | fixup *
1.7.0.txt:* git rebase -i学到了新的动作fixup,它压缩了变化
1.7.0.txt,但不影响现有的日志消息。
-
1.7.0.txt:*git rebase -i也学到了--autosquash选项很有用
1.7.0.txt:连同新的fixup动作。
1.7.0.txt-
-
1.7.3.txt:*git rebase -i偷看到rebase.autosquash配置,并且充当
1.7.3。 txt:如果你从命令行给了--autosquash。
1.7.3.txt-
-
1.7.4.txt:*git commitlearn --fixup和--squash选项,以帮助稍后调用
1.7。 4.txt-交互式底座。
-
1.7.4.txt:*git rebase --autosquash可以使用SHA-1对象名来命名
1.7.4.txt:提交修正fixup!e83c5163)。
1.7.4.txt-
Suppose you have:
A-B-C
Now your build/test fails. The fix should be merged in A. My current work-flow is like this:
$ git commit -m "fixA"
A-B-C-fixA
$ git rebase -i A~1
And squash fixA in A, result in:
A'-B-C
Is there a command to do something like:
A-B-C + (index with fix for A)
$ git commit -supperdupper A
Result:
A'-B-C
If you're just looking for the easy solution for fixing up earlier commits, read the question! It explains it all. But since Elmarco was asking for a slick way, here we go:
As of Git 1.7.0, there is an --autosquash
option for rebase
, which does what you want. There is also the --fixup
and --squash
options for commit
to make things easier. With some aliasing you can probably even get the whole thing into a single command.
I'd suggest upgrading to the newest Git for maximum awesomeness:
git/Documentation/RelNotes $ grep -i -A1 autosquash\\\|fixup *
1.7.0.txt: * "git rebase -i" learned new action "fixup" that squashes the change
1.7.0.txt- but does not affect existing log message.
--
1.7.0.txt: * "git rebase -i" also learned --autosquash option that is useful
1.7.0.txt: together with the new "fixup" action.
1.7.0.txt-
--
1.7.3.txt: * "git rebase -i" peeks into rebase.autosquash configuration and acts as
1.7.3.txt: if you gave --autosquash from the command line.
1.7.3.txt-
--
1.7.4.txt: * "git commit" learned --fixup and --squash options to help later invocation
1.7.4.txt- of the interactive rebase.
--
1.7.4.txt: * "git rebase --autosquash" can use SHA-1 object names to name which
1.7.4.txt: commit to fix up (e.g. "fixup! e83c5163").
1.7.4.txt-
这篇关于git:压扁/修复先前的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!