我有两个分支,它们包含自己版本的node_modules,但在不同的文件夹中。
分公司1:
--client/
--server/
--node_modules/
...分公司2:
--server/
-----/node_modules/
...因此,当我从Branch 2 -> Branch 1切换时,它包含以下文件夹:
--client/
--server/
-----/node_modules/
--node_modules/
...这造成了一个错误,因为Node将使用嵌套版本而不是外部版本。因此,我的问题是,在签出另一个分支时,如何将.gitignore中指定的文件(例如,本例中的node_modules )消失?
发布于 2015-11-20 05:52:22
你可以试试(试运行测试)。
git clean -d -x -n查看一下,在git签出之后,是否会删除正确的文件。
见"How do I clear my local working directory in git?“
另一种方法是紧跟在git reset --hard之后的git checkout。
如果您不能轻松地删除(.gitignore'd) node_modules文件夹,那么第三种方法是在两个不同的文件夹中工作,每个分支一个。
参见"Multiple working directories with Git?":从Git 2.5+开始,您可以克隆一次,并在不同的文件夹中签出不同的分支。
切换分支变得和cd ../otherbranch一样容易。
https://stackoverflow.com/questions/33818991
复制相似问题