O'Reilly logo

Git Essentials - Second Edition by Ferdinando Santacroce

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Removing changes from the staging area

It happens that you add changes to the staging area, then you realize they fit better in a future commit, not in the commit you are composing right now.

To remove those changes to one or more files from the staging area, you can use the git reset HEAD <file> command; get back the shell and follow me.

Check the repository current status:

[16] ~/grocery (master)
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

modified:   shoppingList.txt

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

modified:   shoppingList.txt

This is the actual situation, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required