S
S
Stnslvtvrn2021-01-06 00:48:28
git
Stnslvtvrn, 2021-01-06 00:48:28

Why the difference between documentation and actual GIT commands?

Good day to all. In the process of studying GIT, I encountered an extremely interesting phenomenon. I will say right away that I am learning it based on git-scm and githowto.

The essence of the issue is the difference between the commands offered by the git to cancel certain actions.
In all tutorials, this is:
(use "git checkout -- ..." to discard changes in working directory)
(use "git reset HEAD ..." to unstage)

But in fact, when working with git-bash, we get the following picture
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git restore ..." to discard changes in working directory)
modified: hello.html


and

$ git st
On branch master
Changes to be committed:
(use "git restore --staged ..." to unstage)
modified: hello.html


Why is that? And what is the best way to use.
For clarity, I am attaching a screen:
5ff4dde0635a1199000813.png
5ff4de3e9ef64644973389.png
The second screen is taken from the site: https://git-scm.com/book/en/v2/Git-Basics-Recordin...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynn "Coffee Man", 2021-01-06
@Stnslvtvrn

The git restore command (and git switch) are relatively new, with version 2.23 in August 2019.
They are designed as simpler replacements for the main uses of git checkout to make it easier for newbies (and not only).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question