简体   繁体   English

如何在不跟踪文件的情况下将文件添加到git项目?

[英]How do I add files to a git project without them being tracked?

I have downloaded a repo from github to a dev server. 我已经从github下载了一个仓库到开发服务器。 The repo does not have a media/ dir. 回购没有媒体/目录。 I copied the media/ folder from the live site to the dev site, however, git picked it up. 我将媒体/文件夹从实时站点复制到了开发站点,但是,git选中了它。 So now when I try to pull files, I'm out of sync. 所以现在当我尝试拉文件时,我不同步了。

So I added media/ to the .gitignore file (which is in VC). 因此,我将媒体/添加到了.gitignore文件(在VC中)。 The problem is, that git now tracks the changes to that, and I still cannot do a git pull. 问题是,git现在跟踪该更改,而我仍然不能执行git pull。

This server will only ever pull files. 该服务器将仅提取文件。

What's the best way to handle this problem? 解决此问题的最佳方法是什么?

So as I understand it, you want to exclude a directory from version control in your own private copy of a repo. 因此,据我所知,您想从版本控制中将目录排除在您自己的仓库的私有副本中。 This is easy: there are two places that Git looks for paths to ignore, the .gitignore file (which is usually tracked in the project commit history), and .git/info/exclude (which is private to your copy of the repo). 这很容易:Git在两个地方寻找要忽略的路径, .gitignore文件(通常在项目提交历史记录中进行跟踪)和.git/info/exclude (这是您的存储库副本专用的) 。 Add the path you want to exclude to the latter, and that will avoid problems pulling from the server in future. 将要排除的路径添加到后者,这样可以避免将来从服务器拉出问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Git忽略被跟踪的文件而不删除它们 - Git ignore files being tracked WITHOUT DELETING THEM 如何让 git 显示正在跟踪的文件列表? - How can I make git show a list of the files that are being tracked? 为什么在提交之前必须添加要跟踪的文件? - Why do I have to add the files being tracked before committing? 如何获取 Eclipse 以查看 git 存储库中有新文件并将它们添加到项目中 - How do I get Eclipse to see that there are new files in a git repository and add them to the project Git合并-不提交跟踪文件而不提交它们 - Git merge --no-commit tracked files without committing them 为我的 Laravel 项目创建 git 存储库后未跟踪文件 - Files are not being tracked after creating a git repo for my laravel project 如何在 git 中保留 png 文件而不跟踪它们? - How do I keep png files in git without tracking them? 如何将git添加到尚未跟踪但git具有完整历史记录的现有项目中 - How can I add git to an existing project which hasn't been tracked but git has a full history 如何列出git未跟踪的文件并按照修改时间排序? - How to list files not tracked by git and sort them according to modification time? 如何获取git以添加已经在另一个git存储库下跟踪的文件? - How can I get git to add files already tracked under another git repository?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM