git - 签出且未合并 Visual Studio 时,添加到分支 dev 的文件显示在另一个分支中
问题描述
我有两个分支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)
有人可以向我解释这种行为吗?为什么这个文件在他们之间共享?我开始知道我应该在签出之前上演然后存储这个文件。
但我仍然想了解这种行为。为什么不只为开发分支保留它?有时我忘记在结帐前准备和存储更改,这会造成巨大的混乱
解决方案
在它被提交到 git 之前(即当文件未被跟踪时),它不在任何分支上。因此,无论您在哪个分支上,该文件仍然会在本地存在。
推荐阅读
- java - 如何在 Spring/HTML 中创建一个实时更新新数据条目/删除而不刷新的表?
- mysql - mysql:使用多表查询时count()很慢
- javascript - Select2 jQuery 控件显示两个下拉列表?
- javascript - 基于浏览器主题动态添加图片
- mocha.js - Mocha 测试验证 Solidity 合约余额
- google-apps-script - 如果第 1 行已填满且用户需要订购超过 1 个产品,如何在 Material Request Web 应用程序中添加新行
- emacs - 如何在 Emacs 中使用 Isabelle
- python - 有效地搜索在 Python 中返回新值的函数的参数
- javascript - 为什么一个表单按钮对所有表单按钮执行操作?
- c++ - 如何从 CLion 获取 C++ 项目并将其移至 QT Creator?