git update-index --assume-unchanged .\src\main\resources\application.properties
我在本地目录中运行了该命令,正如我所料,该文件从 VS Code的部分中application.properties
消失了。Changes
Source Control
但是,差异仍然显示红色删除和绿色添加,就好像文件仍在被跟踪一样。<-- 这显示在下面的屏幕截图中
我也阻止切换分支,因为“更改会覆盖该文件”
任何想法为什么会发生这种情况?我想在我的远程存储库中有一个基本版本,我可以在本地更改而不跟踪更改。
我看到了该--skip-worktree
选项并尝试git update-index --skip-worktree .\src\main\resources\application.properties
了,但得到了相同的结果。
这是 git 命令和输出
PS C:\r\Body-Tracking-Uploader> git update-index --assume-unchanged .\src\main\resources\application.properties
PS C:\r\Body-Tracking-Uploader> git status
On branch upload-exerciseInfo-aws
Your branch is up to date with 'origin/upload-exerciseInfo-aws'.
nothing to commit, working tree clean
PS C:\r\Body-Tracking-Uploader> git branch
main
* upload-exerciseInfo-aws
PS C:\r\Body-Tracking-Uploader> git checkout main
error: Your local changes to the following files would be overwritten by checkout:
src/main/resources/application.properties
Please commit your changes or stash them before you switch branches.
Aborting
PS C:\r\Body-Tracking-Uploader>