gitpractice.dev

brewly — Ch.1 · You'll see this elsewhere

Exercise 8 of 11

Before you start

Before restore existed

git restore is fairly new. Older guides and many colleagues use reset and checkout for the same two jobs. Both still work.

In git checkout -- <file>, the -- tells git that what follows is a file name, not a branch name.

git reset HEAD <file>
unstage, like git restore --staged <file>
git checkout -- <file>
discard changes, like git restore <file>
git status
check the result
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