git忽略了仍在追踪的文件 [英] git ignored files still being tracked

查看:229
本文介绍了git忽略了仍在追踪的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  config / template.json 
config / test.json

我修改了它们并希望永远忽略它们。我试图通过将它们添加到根 .gitignore

  / config 
config / template.json
config / test.json

和因为它不起作用,所以也对 config .gitignore

  template.json 
test.json

问题:当我 git pull 时,它说:

 错误:对以下文件的本地更改将被合并覆盖:
config / template.json
config / test.json
请在提交更改或隐藏它们之前进行合并。
正在取消

我希望我的更改保持本地化并发送到远程回购站。这是怎么回事?我没有忽略这些文件吗? ?怎么办


解决方案

它在的文档




A gitignore 文件指定Git应该忽略的有意未覆盖的文件。已经Git的跟踪文件不会受到影响。




当您将文件添加到的.gitignore 您还必须使用以下命令将其从存储库中删除:

  git rm --cached文件名


There are 2 files tracked by git.

config/template.json
config/test.json

I modified them and want to ignore them forever. I tried to do that by adding them to the root .gitignore

/config
config/template.json
config/test.json

and since it did not work, also to the config .gitignore

template.json
test.json

Problem: when I git pull, it says:

error: Your local changes to the following files would be overwritten by merge:
    config/template.json
    config/test.json
Please, commit your changes or stash them before you can merge.
Aborting

I want my changes to stay local and be sent to the remote repo. What's going on? Did I not ignore these files? What to do?

解决方案

It is explained in the first paragraph of the documentation:

A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected.

When you add a file to .gitignore you have to also remove it from the repository using the command:

git rm --cached filename

这篇关于git忽略了仍在追踪的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆