忽略git-svn中的目录(将目录添加到稀疏检出) [英] Unignore directories in git-svn (adding directories to a sparse checkout)

查看:208
本文介绍了忽略git-svn中的目录(将目录添加到稀疏检出)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用git svn时,可以通过以下方式实现对中央存储库的稀疏检出

git clone -s URL-to-root --include-paths 'dir1|dir2|dir3'

使用此设置一段时间后,我想向被跟踪的目录添加另一个目录dir4.我已经签出的许多提交中都存在该目录.通过运行编辑变量svn-remote.svn.include-paths

git config --edit

git fetch并没有达到预期的效果(仅在以后的提交中更改的文件会在更改时被检出;不会立即检出),并且以下内容也不会检出dir4:

git svn fetch --include-paths dir4

我认为以下方法会起作用,但由于重新获取自第一次出现dir4的第一个修订版以来的所有修订版本(我们将其称为REV),效果非常差:

git svn reset -r REV
git svn fetch --include-paths dir4
git svn rebase

什么是跟踪dir4的更好方法?如果我不在乎dir4的历史怎么办?

如果我怀疑以后要更改跟踪目录的列表,是否有更好的方法使用git-svn进行初始稀疏签出?我也尝试过列出无法在原始提交中获取的目录,但是我不知道以后如何忽略它们.

git svn fetch --ignore-paths dir4

但是当我决定也要检出它时,如何告诉git停止忽略dir4?

解决方案

git-svn手册页的reset部分

我认为原因是这样的:Git为svn历史记录中的每个svn提交创建一个单独的git commit(由其校验和标识).通过在历史记录中添加目录,校验和必定必须更改,因此除了重建整个历史记录外别无其他方法.

即使不重新创建历史记录,也无法添加目录.添加该提交的提交必须在本地创建,并且尝试对其进行svn dcommit时,会出现错误Item already exists in filesystem...

When using git svn, a sparse checkout of the central repository may be achieved by something along the lines of

git clone -s URL-to-root --include-paths 'dir1|dir2|dir3'

After using this setup for some time, I would like to add another directory dir4 to those tracked. This directory has existed in many commits that I have already checked out. Editing the variable svn-remote.svn.include-paths by running

git config --edit

does not have the desired effect on git fetch (only files changed in future commits will be checked out as they are changed; not immediately), and the following also does not check out dir4:

git svn fetch --include-paths dir4

I think the following would work but would be very ineffective due to refetching all revisions since the first revision at which dir4 appeared for the first time (let's call it REV):

git svn reset -r REV
git svn fetch --include-paths dir4
git svn rebase

What would be a better way of tracking dir4? What if I do not care about the history of dir4?

Is there a better way to do the initial sparse checkout with git-svn if I suspect I will want to change the list of tracked directories later? I have also tried starting by listing the directoreis that are not to be fetched in the original commit, but I do not know how to unignore them later:

git svn fetch --ignore-paths dir4

But how do I tell git to stop ignoring dir4 when I decide I want to check it out as well?

解决方案

The reset section of git-svn man page https://git-scm.com/docs/git-svn/1.9.1#git-svn-emresetem states this:

... if you alter your --ignore-paths option, a fetch may fail with "not found in commit" (file not previously visible) or "checksum mismatch" (missed a modification). If the problem file cannot be ignored forever (with --ignore-paths) the only way to repair the repo is to use reset.

I think the reason is this: Git creates a separate git commit (identified by its checksum) for each svn commit in the svn history. By adding a directory to the history, the checksums necessarily have to change, so there is no way other than rebuilding the whole history.

The directory cannot be added even without recreating the history. A commit adding it would have to be created locally, and on an attempt to svn dcommit it, there is an error Item already exists in filesystem...

这篇关于忽略git-svn中的目录(将目录添加到稀疏检出)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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