Git 拉取 .gitignore 中的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26843187/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git pulls files in .gitignore
提问by VonC
I use Git pull to download changes from remote repo to my local dev folder. the problem is every time I pull changes, git downloads some file that exists in .gitignore file (e.g. /app/config/config.yml)
我使用 Git pull 将更改从远程存储库下载到我的本地开发文件夹。问题是每次我拉更改时,git 都会下载一些存在于 .gitignore 文件中的文件(例如 /app/config/config.yml)
what am I doing wrong ?? here is my .gitignore
我究竟做错了什么 ??这是我的 .gitignore
# Parameters
/app/config/parameters.yml
/app/config/parameters.ini
/app/config/config.yml
but when I pull git pull
I find a new config.yml !!
但是当我拉git pull
我找到一个新的 config.yml !!
采纳答案by zerkms
.gitignore
only ignores untracked files. It does not have any influence to the ones that have already been committed.
.gitignore
只忽略未跟踪的文件。它对已经提交的那些没有任何影响。
The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked.
gitignore 文件的目的是确保 Git 未跟踪的某些文件保持未跟踪状态。
References:
参考:
回答by VonC
Check if your local config.yml is actualy ignored, or if it is currently versioned.
检查您的本地 config.yml 是否被实际忽略,或者它当前是否已版本化。
git check-ignore -v -- app/config/config.yml
If it isn't ignored, you need to remove from the index and record that deletion
如果没有被忽略,则需要从索引中删除并记录该删除
git rm --cached -- app/config/config.yml
git commit -m "delete config.yml"
git push
Then the next pull wouldn't bring that file back.
然后下一次拉取不会带回该文件。
But, as commentedby Shichu Zhu, it also means the next git pull
will, for othercollaborator, will delete their local config.yml
.
So you need to communicate that, for them to do something like this answer.
但是,正如Shichu Zhu所评论的,这也意味着下一个将,对于其他合作者,将删除他们本地的.
所以你需要传达这一点,让他们做类似这个答案的事情。git pull
config.yml