How do you move a commit to the staging area in git?

If you want to move a commit to the staging area – that is uncommit it and move all of the changes which were in it into the staging area (effectively putting the branch in the state that it would have been in prior to the commit) – how do you do it? Or is it something that you can’t do?

The closest that I know how to do is to copy all of the files that were changed in the commit to somewhere else, reset the branch to the commit before the commit that you’re trying to move into the staging area, move all of the copied files back into the repository, and then add them to the staging area. It works, but it’s not exactly a nice solution. What I’d like to be able to do is just undo the commit and move its changing into the staging area. Can it be done? And if so, how?

  • List all commits for a specific file
  • What happens in Git to a tag when you amend the commit that was tagged?
  • Can you change a file content during git commit?
  • Getting “CHECKOUT can only be performed on a version resource” when trying to commit using Eclipse subversive plugin
  • Build on commit with subversion
  • How to copy a commit from one branch to another in git without any merging?
  • Git Clone - Repository not found
  • Why is a stash represented as 2 commits?
  • setting tabwidth to 4 in git show / git diff
  • Comparing two branches in Git?
  • XCode (git) failed to commit files
  • Git: Best way to add only some parts of a file from another branch?
  • One Solution collect form web for “How do you move a commit to the staging area in git?”

    git reset --soft HEAD^

    This will reset your index to HEAD^ (the previous commit) but leave your changes in the staging area.

    There are some handy diagrams in the git-reset docs

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