git reset --hard似乎忽略了.git / info / exclude [英] git reset --hard seems to ignore .git/info/exclude

查看:345
本文介绍了git reset --hard似乎忽略了.git / info / exclude的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b $我们有一个共享目录(称为/共享),通过运行这些命令,我​​们可以自动保持与主git分支的最新状态。 b

 
git reset --hard HEAD
git clean -f -d
git pull

这大部分工作。但是,即使有一个媒体符号链接签入git,我们仍然无法触及目录/共享/媒体。



我已经将媒体添加到.git / info / exclude,但无论如何,git reset --hard HEAD将删除/共享/媒体,并用检入的符号链接替换它。



有没有办法让git reset --hard HEAD离开这个目录,除了eg通过事先将它移开并在之后恢复它?解析方案

您不能忽略存储实际内容的路径在git仓库中反对它。 Git会对所跟踪的树进行修改。忽略仅影响尝试开始跟踪新内容,需要 add -f 来实际存储新内容。



但您忽略路径 .gitignore .git / info / exclude 或通过 core.excludesfile 配置。



如果您不想通过硬重置删除媒体目录,则需要删除来自存储库的冲突路径。除了明确重置其他路径之外,没有解决方法。


We have a shared directory (call it /shared) that we keep automatically up to date with our master git branch, by running these commands whenever there is a push to master:

   git reset --hard HEAD
   git clean -f -d
   git pull

This works for the most part. However there is a directory /shared/media that we don't want to be touched, even though there is a "media" symlink checked into git.

I've added "media" to .git/info/exclude, but regardless, "git reset --hard HEAD" removes /shared/media and replaces it with the checked in symlink.

Is there any way to get "git reset --hard HEAD" to leave this directory alone, other than e.g. by moving it out of the way beforehand and restoring it afterwards?

解决方案

You can't ignore a path that has actual content stored against it in a git repository. Git will honour changes to the tracked tree. Ignoring only affects attempts to start tracking new content, requiring an add -f to actually store new content.

This holds however you ignore a path, .gitignore, .git/info/exclude or via a core.excludesfile configuration.

If you don't want your media directory to be removed by a hard reset, you need to remove the conflicting path from the repository. Other than explicitly resetting only other paths, there is no workaround.

这篇关于git reset --hard似乎忽略了.git / info / exclude的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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