git commit gives error: empty commit set passed

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

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

However this gave an error:

  • How to make git output show red or orange color when it contains the word “error”, “warning”, or “Aborting”?
  • How to pull in changes from skeleton sub-repository into production super-repository
  • What happened to my these several times git pull --rebase with the error “Your local changes to the following files would be overwritten by merge”
  • GIT SSH public key error
  • Unable to execute git tf command
  • Applying the changes from branch b to a, without merging or adding commits
  • empty commit set passed

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

  • How can I keep my fork in sync without adding a separate remote?
  • Is there a git equivalent to clearcase catcr
  • Two different Git repo in same directory
  • Why do GitHub HTTPS schemes always ask for my password?
  • Git: Remove all revisions of a file in a repository, and replace with new file
  • How to make existing git branch track a remote branch?
  • 2 Solutions collect form web for “git commit gives error: empty commit set passed”

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

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

    The gitpro book explains the double dot annotation pretty solid:

    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.

    Figure 6-1. Example history for range selection.

    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

    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

    The whole chapter can be found here.

    Remove the ..HEAD part. At least on my system (git v2.7.4) this resolved the issue.

    git revert –no-commit 0766c053

    Git Baby is a git and github fan, let's start git clone.