0

我创建了一个分支 temp。
我安装了新版本的 express 模块。我将 node_modules 文件夹添加到 .gitignore。

[ubuntu@ip-172-31-10-215:~/bitstarter]$git checkout master
error: The following untracked working tree files would be overwritten by checkout:
        node_modules/.bin/express
        node_modules/express/.npmignore
        node_modules/express/History.md
        node_modules/express/LICENSE
        node_modules/express/Makefile
        node_modules/express/Readme.md
        node_modules/express/bin/express
        node_modules/express/index.js
        node_modules/express/lib/express.js
        node_modules/express/lib/request.js
        node_modules/express/lib/response.js
        node_modules/express/lib/router/index.js
        node_modules/express/lib/router/route.js
        node_modules/express/lib/utils.js
        node_modules/express/lib/view.js
        node_modules/express/node_modules/connect/.npmignore
        node_modules/express/node_modules/connect/LICENSE
        node_modules/express/node_modules/connect/index.js
        node_modules/express/node_modules/connect/lib/cache.js
        node_modules/express/node_modules/connect/lib/connect.js
        node_modules/express/node_modules/connect/lib/index.js
        node_modules/express/node_modules/connect/lib/middleware/basicAuth.js
        node_modules/express/node_modules/connect/lib/middleware/bodyParser.js
        node_modules/express/node_modules/connect/lib/middleware/compress.js
        node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
        node_modules/express/node_modules/connect/lib/middleware/csrf.js
        node_modules/express/node_modules/connect/lib/middleware/directory.js
        node_modules/express/node_modules/connect/lib/middleware/errorHandler.js
        node_modules/express/node_modules/connect/lib/middleware/favicon.js
        node_modules/express/node_modules/connect/lib/middleware/limit.js
        node_modules/express/node_modules/connect/lib/middleware/logger.js
        node_modules/express/node_modules/connect/lib/middleware/methodOverride.js
        node_modules/express/node_modules/connect/lib/middleware/query.js
        node_modules/express/node_modules/connect/lib/middleware/responseTime.js
        node_modules/express/node_modules/connect/lib/middleware/session.js
        node_modules/express/node_modules/connect/lib/middleware/session/cookie.js
        node_modules/express/node_modules/connect/lib/middleware/session/memory.js
        node_modules/express/node_modules/connect/lib/middleware/session/session.js
        node_modules/express/node_modules/connect/lib/middleware/session/store.js
        node_modules/express/node_modules/connect/lib/middleware/static.js
        node_modules/express/node_modules/connect/lib/middleware/staticCache.js
        node_modules/express/node_modules/connect/lib/middleware/vhost.js
        node_modules/express/node_modules/connect/lib/patch.js
        node_modules/express/node_modules/connect/lib/public/directory.html
        node_modules/express/node_modules/connect/lib/public/error.html
        node_modules/express/node_modules/connect/lib/public/favicon.ico
        node_modules/express/node_modules/connect/lib/public/icons/page.png
        node_modules/express/node_modules/connect/lib/public/icons/page_add.png
        node_modules/express/node_modules/connect/lib/public/icons/page_attach.png
        node_modules/express/node_modules/connect/lib/public/icons/page_code.png
        node_modules/express/node_modules/connect/lib/public/icons/page_copy.png
        node_modules/express/node_modules/connect/lib/public/icons/page_delete.png
        node_modules/express/node_modules/connect/lib/public/icons/page_edit.png
        node_modules/express/node_modules/connect/lib/public/icons/page_error.png
        node_modules/express/node_modules/connect/lib/public/icons/page_excel.png
        node_modules/express/node_modules/connect/lib/public/icons/page_find.png
        node_modules/express/node_modules/connect/lib/public/icons/page_gear.png
        node_modules/express/node_modules/connect/lib/public/icons/page_go.png
        node_modules/express/node_modules/connect/lib/public/icons/page_green.png
        node_modules/express/node_modules/connect/lib/public/icons/page_key.png
        node_modules/express/node_modules/connect/lib/public/icons/page_lightning.png
        node_modules/express/node_modules/connect/lib/public/icons/page_link.png
        node_modules/express/node_modules/connect/lib/public/icons/page_paintbrush.png
        node_modules/express/node_modules/connect/lib/public/icons/page_paste.png
        node_modules/express/node_modules/connect/lib/public/icons/page_red.png
        nod
Aborting

这是 git status (为了好玩):

[ubuntu@ip-172-31-10-215:~/bitstarter]$git status
# On branch temp
nothing to commit (working directory clean)

现在是晚上 1:30,所以我累死了,我一辈子都找不到干净的解决方案(害怕失去我的工作或弄乱依赖关系或其他东西)。
明天我会检查答案非常感谢您!

4

2 回答 2

1

看起来您在将规则添加到.gitignore.

您可以使用git rm --cached <file>.

为了切换带有脏目录的分支,通常最快和最简单的就是stash更改。

于 2013-08-16T05:31:45.740 回答
0

如果你刚刚安装了新版本,并且之前的文件已经被 git 跟踪过,你可以取消跟踪已经添加到 git 中的文件。

git rm --cached filename

Git 将停止跟踪这些文件,现在将该文件夹添加到 .gitignore。

于 2013-08-16T06:35:47.053 回答