shellstreak

Undo git add . (unstage everything)

Safe: nothing is lost

Short answer

Run git restore --staged . from the top of the repository. Nothing is staged any more, and your files keep every change.

The commands, one by one

  1. 1git restore --staged .

    . means this folder and everything in it, so every staged file is unstaged. Files on disk don't change.

  2. 2git status -s

    New files are back to ?? (untracked) and edited ones show M in the second column.

Try it safely

git add . staged your recipe edit and a debug.log you never meant to commit.

learner@shellstreak: ~
Starting your practice shell…

Type your own commands too. Reset puts the repository back to just after the mistake.

Practise this in 5 minutes

Lesson 28, Undo changes, walks you through this undo and the ones around it in a safe terminal, step by step, and checks your answers.

Keep the terminal cheat sheet handy: free to print

Get the shellstreak newsletter

Short terminal and Git tips you can try in a minute, plus a heads-up when new free tools and lessons ship. It lands now and then, never a flood.

No spam, unsubscribe in one click.