Gabriel Ferraz
Gabriel Ferraz

Reputation: 632

What is the simplest way to reset all staged files in Git?

I have used git reset before for single files but I frequently find myself having to unstage multiple files before a commit. Is there a command that unstages all staged files? I couldn't find it on the documentation (http://git-scm.com/docs/git-reset).

Upvotes: 7

Views: 10249

Answers (3)

René Link
René Link

Reputation: 51373

git status usually shows you the options, e.g.

On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

    modified:   someFile.txt
    modified:   someDir/someOtherFile.txt

So if you want to unstage all files just do what git proposes

git reset HEAD

EDIT

Since Git 2.23 you can use git restore --staged. git restore can also restore working tree files from another commit (-s) and run interactively (-p). There are even more interessting options available. See the git restore documentation.

Upvotes: 13

Arjang
Arjang

Reputation: 729

I use SourceTree client. It has option for Stage and UnStage all files. You can also use it in combination with command line.

Upvotes: 0

Try this:

git reset HEAD .

Git should actually write what to do, when you execute git status

6:16:17 {proj_main} ~/git/proj_main$ git status
On branch proj_main
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   sub_proj/.project

Upvotes: 1

Related Questions