gpt4 book ai didi

git - 有时恢复,有时 checkout

转载 作者:行者123 更新时间:2023-12-04 00:53:57 24 4
gpt4 key购买 nike

我开始注意到,有时当我输入 git status 来检查一个分支时,我会看到文本:

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

有时我会看到:

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

它开始吓坏我了。这是怎么回事?

最佳答案

您几乎肯定会在两台不同的计算机上看到这些消息,或者在运行两个不同版本的不同二进制文件时看到这些消息。 git restore was introduced in 2.23 , 并且帮助消息在那之后不久发生了变化(我不记得确切的版本,或者它没有在 changelogs 中提到,或者我很密集而找不到它)。

git restore <file>git checkout -- <file>做同样的事情,所以除了好奇之外没有必要担心差异。 git checkout是一个执行大量不同操作的困惑命令——git switch 的介绍和 git restore试图在不改变功能的情况下使其对初学者更直观。

关于git - 有时恢复,有时 checkout ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64190617/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com