How to undo staged changes added by git add before commit?

You can use git restore –staged command to undo staged changes added by git add command.

Example:

Create a new git local repository:

Create first commit:

Check git status:

Do some changes in working tree:

Check git status:

Stage the changes from working tree to the staging area:

Check git status:

Undo staged changes added by git add command:

Check git status:

Undo unstaged changes:

Check git status:

Remove the local git repository:

Leave a Reply