git commit给出错误:传递了空的提交集 [英] git commit gives error: empty commit set passed

查看:339
本文介绍了git commit给出错误:传递了空的提交集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试还原到先前的提交时,我尝试了:

When trying to revert to a previous commit, I tried:

git revert --no-commit 0766c053..HEAD

但是这给出了一个错误:

However this gave an error:

empty commit set passed

问题:错误是什么意思,revert命令出了什么问题?

Question: What does the error mean, and what went wrong with the revert command?

推荐答案

在我看来,您误用了double dot注释来指定提交范围.

It seems to me that you misused the double dot annotation to specify a commit range.

因此,您的范围不会返回任何提交,这意味着revert无法执行任何操作,因为您有效地说"不返回任何提交".

So your range doesn't return any commits which means that revert can't do anything, since you effictively said "revert no commits".

gitpro书解释了

The gitpro book explains the double dot annotation (link to chapter) pretty solid:

最常见的范围规范是双点语法.这基本上是要求Git解决一次提交可达到但另一次无法实现的一系列提交.例如,假设您有一个类似于图6-1的提交历史记录.

The most common range specification is the double-dot syntax. This basically asks Git to resolve a range of commits that are reachable from one commit but aren’t reachable from another. For example, say you have a commit history that looks like Figure 6-1.

您想查看实验分支中尚未合并到主分支中的内容.您可以要求Git向您显示带有master..experiment的那些提交的日志,这意味着所有可通过实验访问的提交,而不能被主服务器访问的提交".为了简洁明了,在这些示例中,我将使用图中的提交对象的字母代替实际的日志输出,其显示顺序如下:

You want to see what is in your experiment branch that hasn’t yet been merged into your master branch. You can ask Git to show you a log of just those commits with master..experiment — that means "all commits reachable by experiment that aren’t reachable by master." For the sake of brevity and clarity in these examples, I’ll use the letters of the commit objects from the diagram in place of the actual log output in the order that they would display:

$ git log master..experiment
D
C

$ git log master..experiment
D
C

另一方面,如果您想看到相反的情况–在master中的所有提交都不在experiment中,则可以反转分支名称. experiment..master向您显示master中所有无法通过experiment访问的内容:

If, on the other hand, you want to see the opposite — all commits in master that aren’t in experiment — you can reverse the branch names. experiment..master shows you everything in master not reachable from experiment:

$ git log experiment..master
F
E

$ git log experiment..master
F
E

这篇关于git commit给出错误:传递了空的提交集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆