是否有任何Git命令将我们所有丑陋的提交合并为一个? [英] Are there any Git command to combine all our ugly commits together to one?
问题描述
当我在本地编写代码时,有时会提交尚未完成的代码,或者以丑陋消息作为临时修订。
但是,当我希望我的代码与其他人合并,我只希望其他人可以看到的最终快照(隐藏难看的修订版)。
我将0分叉到我的本地存储库,我做了更改和测试,并提交了不干净的代码
0-> 1-> 2-> 3-> 4 - > 5-> 6(最终代码)
当其他人拉代码时,是否有可能让其他人看到最终状态?而不是从1..5看到树
我希望用户看到像
0 --- ----------------> 6
我可以想到的一种方法是制作一个补丁文件,但它不好足够的,如果有一些文件必须删除或创建。
我使用@ mark-longair和@ charles- baily完成我的工作
假设我有分支...
master:A - > B - > C
功能:\ - > D - > E - > F
第一种方式,工作目录为'特征'分支
git reset --soft< A-hash>
git commit -m
我们不会看到任何以前的提交,必须写入新的提交信息
第二种方式,工作目录是'功能'分支
<$来自编辑器的p $ p>
git rebase -i
,从选择为压扁(或简称 s ),除第一个提交外
选择00bb6f9 D
s 4a251d9 E
s 6047df8 F
完成。通过这种方式,它将显示先前的提交消息,我们可以将其编辑为最终提交。
When I write the code in local, sometime I commit the code that isn't clean yet, or, with ugly message as temporary revision.
However, when I want my code to merge with the others, I would like only final snapshot that the other can see, (hidden the revisions that look ugly)
Ex. I fork 0 to my local repository, I make change and test and commit with unclean code
0->1->2->3->4->5->6 (Final code)
when the others pull the code, is it possible to make other see only final state? and not see the tree from 1..5
I want users will see like
0------------------->6
One way I can think of, is make a patch file, but it not good enough if there are some file have to be delete or create.
I use answer from @mark-longair and @charles-baily to done my work
Let say I have branch...
master : A --> B --> C
feature : \-->D --> E --> F
first way, working directory is 'feature' branch
git reset --soft <A-hash>
git commit -m
We will not see any previous commit at all, have to write the new commit message
second way, working directory is 'feature' branch
git rebase -i
from Editor, change from pick to squash (or s for short) for all commit except the first one
pick 00bb6f9 D
s 4a251d9 E
s 6047df8 F
Done. With this way, it will show previous commit message that we can edit as the final commit.
这篇关于是否有任何Git命令将我们所有丑陋的提交合并为一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!