Git rebase 交互式删除 vs 删除提交行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35846154/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:50:40  来源:igfitidea点击:

Git rebase interactive drop vs deleting the commit line

gitgit-rebase

提问by Wazery

What is the difference from dropin the Git interactive rebase and just deleting the line of the commit?

drop与 Git 交互式 rebase 和仅删除提交行有什么区别?

回答by Matthieu Moy

There is no difference by default; it's just another way to say the same thing.

默认没有区别;这只是说同一件事的另一种方式。

But,if you set rebase.missingCommitsCheckto warnor error, then removing a line will trigger a warning (useful for detecting a messed-up cut-and-paste).

但是,如果您设置rebase.missingCommitsCheckwarnerror,则删除一行将触发警告(用于检测混乱的剪切和粘贴)。

Then setting the line to dropexplicitly tells Git that you want to drop that commit, and no warning is shown for it.

然后将该行设置为drop明确告诉 Git 您要删除该提交,并且不会显示任何警告。

回答by Stephen Friedrich

There isin fact another small difference:

还有就是其实另一个小区别:

You can explicitly "drop" all commits. The effect will be the same as a reset.

您可以明确地“删除”所有提交。效果将与重置相同。

However if you just delete all lines, then git will tell you "Nothing to do".

但是,如果您只是删除所有行,那么 git 会告诉您“无事可做”。

Usually you would not use rebase anyway in that case. I learned the difference only when I tried to explain removing a commit with rebase to a co-worker using a dummy commit.

在这种情况下,通常你不会使用 rebase。仅当我尝试向使用虚拟提交的同事解释使用 rebase 删除提交时,我才了解了差异。

回答by MrTux

Marking a commit as dropis the same as deleting the line.

将提交标记为drop与删除该行相同。

The commit will be dropped/ignored.

提交将被删除/忽略。

See when you scroll down:

向下滚动时查看:

If you remove a line here THAT COMMIT WILL BE LOST.

如果您在此处删除一行,则提交将丢失。

The drop command was added in 2.6.0-rc1:

2.6.0-rc1 中添加了 drop 命令:

"git rebase -i" learned "drop commit-object-name subject" command as another way to skip replaying of a commit.

“git rebase -i”学习了“drop commit-object-name subject”命令作为跳过提交重播的另一种方式。