gpt4 book ai didi

git - 在 git 中切换分支 - 我什么时候会得到 "You have local changes cannot switch branches."?

转载 作者:太空狗 更新时间:2023-10-29 14:27:34 29 4
gpt4 key购买 nike

<分区>

Possible Duplicates:
git: Switch branch and ignore any changes without committing.
Git branches behaving strangely

我知道一般建议是在 git 中切换分支之前保持干净状态。 ( stash 或 park-commit )。我试图了解我什么时候会得到“你有本地更改不能切换分支”,我无法遵循逻辑:

我有一个 repo,有一个名为 version.txt 的文件,包含文本“1”:

git checkout -b new

echo 2 >> version.txt (working dir is not dirty, modified the file)

git checkout master ( how come this works ? I have not stages\commited my changes on new )

如果我删除新分支中的文件内容,或者先暂存文件,也会发生同样的情况。

有人可以帮助我了解我什么时候会收到“您有本地更改无法切换分支。” ?

谢谢,冉

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