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

问题描述

我有一个 git 存储库,仅用于保存在多个项目中使用的图形和声音文件.它们都在一个目录中,没有子目录.现在我刚刚创建了一个脚本来从另一个结构化目录复制这些资产,该目录具有多个级别的子目录.

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.

现在我只希望git跟踪(源)分层文件结构,而(目标)平面目录(所有文件在一堆)应该被忽略.

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.

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

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.

如何让 git 忘记目标目录?

How do I make git forget about the target directory?

推荐答案

此命令将导致 git 取消跟踪您的目录及其下的所有文件,而不会实际删除它们:

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

git rm -r --cached

-r 选项会导致删除您目录下的所有文件.

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

--cached 选项导致文件只从 git 的索引中删除,而不是你的工作副本.默认情况下 git rm 会删除 .

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>.

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

09-01 17:09