Unstage Files

In this tutorial, we will demonstrate how to reset files from the staging area.

Unstage files from staging area

After you have added some files to the staging area, you come to a situation that you don’t want to commit this change to the repository because you plan to do more modification on this file, then you need to unstage the file from the staging area. The file change is still in the staging area if you check the git status, and it could be reset with the command git reset HEAD <file>....

Le’t check with our working copy status,

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

	renamed:    test1_rename.txt -> move/test1.txt

We want to unstage this rename, then,

$ git reset HEAD
Unstaged changes after reset
D test1_rename.txtgi

The working copy status changes to

$ git status
On branch master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	deleted:    test1_rename.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	move/

no changes added to commit (use "git add" and/or "git commit -a")

It is back to the status before the rename is staged.