忽略已经签入的目录内容? [英] Ignoring an already checked-in directory's contents?

查看:138
本文介绍了忽略已经签入的目录内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个只用于存放几个项目中使用的图形和声音文件的git仓库。它们都在一个没有子目录的目录中。现在我刚刚创建了一个脚本,将这些资源从另一个结构化目录复制到多级子目录。



现在我只想要(源)分层文件结构要被git跟踪,并且(目标)平面目录(所有文件都在一堆中)应该被忽略。



我已经将目标目录添加到.gitignore,但git仍然在跟踪它的变化。我想如果我提交删除目标目录中的旧文件,git可能会停止跟踪新内容(由脚本复制),但它不会。



如何让git忘记目标目录?

解决方案

这个命令会让git解开你的目录和所有文件在它下面并没有真正删除它们:

git rm -r --cached< your directory>



-r 选项会删除您目录下的所有文件。
$ b - cached 选项会导致这些文件只能从git的索引中删除,而不是您的工作副本。默认情况下, git rm< file> 会删除< file>


I have a git repository that's used only to hold graphics and sound files used in several projects. They are all in one directory without sub-directories. Now I just created a script to copy these assets over from another, structured directory, with several levels of sub-directories.

Now I only want the (source) hierarchical file structure to be tracked by git, and the (target) flat directory (with all the files in one pile) should be ignored.

I've added the target directory to .gitignore, but git is still tracking changes in it. I thought if I commit the deletion of the old file in the target directory, git might stop tracking the new contents (copied in by the script), but it doesn't.

How do I make git forget about the target directory?

解决方案

This command will cause git to untrack your directory and all files under it without actually deleting them:

git rm -r --cached <your directory>

The -r option causes the removal of all files under your directory.

The --cached option causes the files to only be removed from git's index, not your working copy. By default git rm <file> would delete <file>.

这篇关于忽略已经签入的目录内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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