git revert –no-commit without staging

Usually the command git revert automatically creates some commits with commit log messages stating which commits were reverted.

To avoid automatic commit there’s the option -n (or --no-commit).

  • Git - Pull from one remote repo, push to another: can I push names of remotes?
  • Undoing temporary changes with Git
  • Git: Show list of commits during interactive rebase
  • how can i configure android studio to add new line at end of file?
  • .gitignore won't ignore the directory
  • Force git to manual merge even in “obvious” situations
  • But after this command, the reverted files are in the staged area. I can unstage them by using the command git reset HEAD.

    Is there a direct way to revert a commit without committing and staging?

    In other words: is there a direct command to revert a commit applying the changes only to the working directory, without touching the index?

  • What does “would be overwritten by merge” mean?
  • Is there any way to undo the effects of “git revert head”?
  • BitBucket: Host key authentication failed
  • Eclipse Java Projects in Git
  • How can I delete a git alias?
  • For the Jenkins git plugin, where is it recommended to run `git config`?
  • One Solution collect form web for “git revert –no-commit without staging”

    There is no single command for it. As you already noted, you can combine git revert -n with git reset to get the reversion undone in the index.

    Besides that method, you can use git apply -R to “reverse apply” a patch, and you can turn a commit into a patch with git show, so:

    $ git show <rev> | git apply -R

    has the same effect, with one important (but subtle) difference. Let me quote from the git revert documentation and add my own emphasis:

    -n, --no-commit
    Usually the command automatically creates some commits with commit
    log messages stating which commits were reverted. This flag applies
    the changes necessary to revert the named commits to your working
    tree and the index, but does not make the commits. In addition,
    when this option is used, your index does not have to match the
    HEAD commit. The revert is done against the beginning state of your

    In other words, git revert -n operates in, and on, the index, with a side effect of updating your work tree. The git apply command operates (by default anyway) on the work-tree only, and in fact can be used outside a git repository.

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