Just undo GIt's 'commit' command (without reverting files to previous commit)

I want to cancel last GIT commit, without reverting files to previous commit.
I.e. I want to return to state that was one moment before committing – so I can see all new/modified files before committing. It’s possible?

  • How to ignore files starting with numbers in Git?
  • How to replace corrupt Git objects with new ones created from my files, which are fine
  • Why does git's cherry picking with more than one commit fail?
  • git rebase private feature branch
  • Modifying git repository root config
  • capistrano deploy asking for USERNAME / PASSWORD on git ls-remote call
  • Is it possible to upload local images to a GitHub repository directly?
  • Can git retain file owner, permissions, ACLs, and file attributes on a local Windows NTFS machine?
  • How do I setup Carthage to use my own Frameworks that are in private repository like Stash (Bitbucket)?
  • Windows PuTTY - git error - No supported authentication methods
  • Remote origin already exists on 'git push' to a new repository
  • Maintaining project with plugins in git
  • 3 Solutions collect form web for “Just undo GIt's 'commit' command (without reverting files to previous commit)”

    You can use:

    git reset HEAD^
    

    Your last commit will be undone, but the changes in that commit will remain on the filesystem.

    Two options, based on what you want to do (it’s not entirely clear). Either you want to keep the working directory as it is, but want to move the current branch back to the previous commit.

    This can be easily done using git reset:

    git reset HEAD~1
    

    You can also use the --soft option to even keep the index as it is:

    git reset --soft HEAD~1
    

    If you want to keep the branch pointing to the commit it currently points to but you want to actually revert the files to the version of the commit before, then you can do that too. You can use git checkout to checkout the working directory from the previous commit without detaching into that commit:

    git checkout HEAD~1 -- .
    

    Basically by specifying a path (after the --) you are telling Git to not actually check out the commit/branch, but just to check out the state for all the files you listed where . means everything relative to the current directory (so to checkout everything, you should be in the root of your repository).

    I don’t know the reason why you should do this…

    Anyway, a simple solution is:

    • Copy the whole directory in some other location
    • Use git reset –hard commit_nb to reset the git history to the previous commit
    • Overwrite files from the copy to your current path (paying attention to overwrite just files, without the .git/ directory)
    Git Baby is a git and github fan, let's start git clone.