我有两个分支 dev
和 bugfix
在开发上我创建了新文件 TestClass.cs
此文件未暂存。
如果我运行 git status
它会显示
On branch dev
Untracked files:
(use "git add <file>..." to include in what will be committed)
WebApplication1/TestClass.cs
nothing added to commit but untracked files present (use "git add" to track)
然后我运行 git checkout bugfix
现在我也可以在这个分支中看到新添加的类 TestClass.cs
。
所以如果我运行 git status
它会显示
On branch bugfix
Untracked files:
(use "git add <file>..." to include in what will be committed)
WebApplication1/TestClass.cs
nothing added to commit but untracked files present (use "git add" to track)
有人可以向我解释这种行为吗?为什么这个文件在他们之间共享? 我开始知道我应该在签出之前暂存然后隐藏这个文件。
但我仍然想了解这种行为。为什么不只为 dev 分支保留它? 有时我会忘记在结账之前暂存和隐藏更改,这会造成很大的混乱