如何完全忽略 Git 中用户生成的图像?

发布于 2024-10-09 18:49:55 字数 466 浏览 8 评论 0原文

我是 Git 的新手。

我位于“维护”分支,我想切换回“master”,但收到错误:

error: The following untracked working tree files would be overwritten by checkout:
vault/users/1/thumb.jpg
vault/users/1/speck.jpg
vault/users/1/prof.jpg
vault/users/1/mini.jpg
vault/users/1/full.jpg

我认为这些图像被忽略,因为在我的 .gitignore 文件中,我说忽略“vault/”。事实上,在尝试提交时它们不会显示为已修改或添加等。看来忽略起作用了。

那么,当我尝试签出我的主分支时,为什么会出现此错误?

注意:如果这个问题已经得到解答,我深表歉意 - 我做了一些查找,但不知道要搜索什么才能找到我的答案。

I am a newbie to Git.

I am in a branch "maintenance" and I want to switch back to "master", but I am receiving the error:

error: The following untracked working tree files would be overwritten by checkout:
vault/users/1/thumb.jpg
vault/users/1/speck.jpg
vault/users/1/prof.jpg
vault/users/1/mini.jpg
vault/users/1/full.jpg

I thought that these images were being ignored because in my .gitignore file, I said to ignore "vault/". Indeed, they don't show up as modified, or added, etc when trying to commit. It seems like the ignore worked.

So, how come when I try and checkout my master branch, it gives me this error?

NOTE: if this has been answered, I apologize - I did some looking but don't know what to search for to find my answer.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

屌丝范 2024-10-16 18:49:55

似乎有人在之前的提交中添加了这些文件。

我建议您备份这些文件(除非您确定不需要它们),删除它们,然后进行结账。然后,您可以查看日志并找出这些文件的添加时间,并(我猜)创建一个新的提交来删除它们。

It would appear that someone has added those files in a previous commit.

I'd suggest that you back up those files (unless you're sure you don't need them), delete them, then do the checkout. You can then look through the log and find out when those files were added and (I'm guessing) create a new commit that removes them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文