I've started to notice that sometimes when I type git status to check a branch I see the text:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: some_code_or_file.py
And sometimes I see:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: some_code_or_file.py
It's starting to freak me out. What's going on here?
You are almost certainly seeing these messages on two different computers or when running two different binaries at different versions. git restore was introduced in 2.23, and the help message changed shortly after that (I can't remember exactly which version, and either it isn't mentioned in the changelogs or I'm being dense and can't find it).
git restore <file> and git checkout -- <file> do the same thing, so there's no need to be worried about the difference beyond curiosity. git checkout is a mess of a command that does a ton of different things -- the introduction of git switch and git restore is an attempt to make it more intuitive for beginners, without changing functionality.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With