git添加.gitignore中列出的新文件

发布于 2025-02-10 07:15:02 字数 638 浏览 1 评论 0 原文

我创建了我的 .gitignore 并列出了我创建的新文件,但是当我运行 git添加时,Git仍然将它们添加。

在搜索解决方案时,我看到了很多我的类似问题,但是对于每个问题,人们在运行 git add add。命令后创建了 .gitignore ,并且使用删除的缓存文件方法解决了该问题( git rm - cached。),但这对我不起作用,因为在创建 .gitignore 文件之前,从未添加过这些文件。

.gitignore是我的工作目录的根源,看起来像这样:

db.sqlite3
.idea/
venv/
media/

就是我运行 git add。

On branch main
new file:   .idea/vcs.xml
new file:   .idea/workspace.xml
new file:   db.sqlite3
new file:   media/Test.jpg
new file:   media/TestProfilePict.jpg

这 它不起作用吗?

I created my .gitignore and listed the new files I created, but git still add them when I run my git add .

While searching for a solution, I saw a lot of similar question of mine, but for each question people created the .gitignore after running the git add . command, and the problem was solved with the removing cached files method (git rm --cached .), but that didn't work for me since those files were never added before the creation of the .gitignore files.

The .gitignore is at the root of my working directory, and looks like that :

db.sqlite3
.idea/
venv/
media/

And this is what I get when i run git add . and git status:

On branch main
new file:   .idea/vcs.xml
new file:   .idea/workspace.xml
new file:   db.sqlite3
new file:   media/Test.jpg
new file:   media/TestProfilePict.jpg

Any idea why it's not working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文