gitpractice.dev

brewly — Ch.1 · Take it back

Exercise 7 of 11

Before you start

Taking things back

Two different jobs. Unstaging removes a file from the next commit but keeps your edit. Discarding throws the edit away.

Careful: git cannot bring back a discarded change that was never committed or staged.

git status
see what is staged and what is not. It also suggests these commands
git restore --staged <file>
unstage: keep the edit, leave it out of the commit
git restore <file>
discard: throw the edit away
git commit -m "What you did"
commit what is still staged
You can reopen this any time with “Lesson”.

Continue on a desktop

Typing git on a small screen is no fun. Open this page on a laptop or desktop to practise.

Back to the path