我在 .gitignore 文件中忽略了 node_modules
和 bower_components
。每次切换分支后,所有的依赖项都会被删除(除了全局安装的),我不得不重新安装它们。
目前我使用的方法是 git stash save --keep-index --include-untracked —all
,但我想知道是否有更简单的解决方案,在从另一个分支切回来后仍然保留 .gitignore 中的文件夹。
我在 .gitignore 文件中忽略了 node_modules
和 bower_components
。每次切换分支后,所有的依赖项都会被删除(除了全局安装的),我不得不重新安装它们。
目前我使用的方法是 git stash save --keep-index --include-untracked —all
,但我想知道是否有更简单的解决方案,在从另一个分支切回来后仍然保留 .gitignore 中的文件夹。
<directory>
git rm -r --cached <directory>
<directory>
重新添加到.gitignore中node_modules
问题,但bower_components
中仍然存在一些残留被跟踪的文件。fatal: pathspec 'node_modules/' did not match any files
请查看 https://stackoverflow.com/questions/52914838/git-moves-files-folders-with-when-checking-other-branches-although-i-use-stash-b - Imnotapotato