转换SVN仓库git与reposurgeon没有创建.gitignore文件? [英] Convert an SVN repository to git with reposurgeon without creating .gitignore files?

查看:165
本文介绍了转换SVN仓库git与reposurgeon没有创建.gitignore文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用reposurgeon将我的svn转换为git存储库:(如何使用reposurgeon将svn repo转换为git?)。



问题是,转换后的标签显示在我创建标签时的日志中,而不是在他们所属的修订版本的位置。在SVN中,它们显示在它们所属的日志的正确位置,无论后来我创建了它们多久。



似乎必须对此做些什么reposurgeon在每个标签中添加一个.gitignore提交,如下所示:

 #模拟Subversion默认忽略,由reposurgeon生成。 
* .o
* .lo
...
* .pyo
* .rej
*〜
。#*
。*。swp
.DS_store
#分支根目录下svn:ignoreproperty的内容。
*〜
nbproject
* .project

我该如何使reposurgeon不在gitignore中为所有标签创建这样的提交?让它创建一个简单的标签,它不会在时间轴上显示为一个提交?



reposurgeon manual sais:
$ b


user-生成.gitignore



此消息意味着reposurgeon在它正在分析的Subversion存储库中找到.gitignore文件。这可能发生了
,因为有人使用git-svn作为活动网关,并且创建了
忽略,这可能与生成的
.gitignore文件中的那些文件一致,也可能不一致,Subversion忽略属性将
翻译成。您需要制定一项政策决定,确定在转换中忽略哪些设置为
,并可能删除
生成的.gitignore文件或用户创建的文件。


但没有例子如何做出这个决定。我怎样才能管理这个?

解决方案


您需要做出关于哪一组忽略
在转换中的使用,并可能删除生成的
.gitignore文件或用户创建的文件。


转换前是否有.gitignore?如果是这样比较后者。看起来这个政策决定与你的提交顺序问题是分开的,对吗?基本上,这个政策问题只是得到你喜欢的最终的.gitignore。做到这一点。



在git中,.gitignore文件的管理与其他文件完全相同。所以你可以说 git log .gitignore 并查看哪些提交对它有贡献。假定整个.gitignore文件在一个10提交前提交并且你希望它分开。如果是这样,您可以执行 git rebase --interactive HEAD〜11 编辑提交问题。做 git add --partial .gitignore; git commit 为你想要分解的每一行。然后 git rebase --continue 得出结论。



如果您希望每个新的逐项提交都是与他们对应的较大的代码提交,那么您将重新分配-i再次将订单转移并与他们的合作伙伴提交进行压扁。如果这听起来像是不必要的工作,那很可能是。如果可以的话,我建议你关注回购的最终状态的完整性,而不是完美的历史表达。



注意:我不明白在这种情况下使用术语标签,因为SVN和git都有标签,但你似乎并不是指两者。也许忽略线或进入会更清楚。

在版本控制中清除历史记录存在问题。改变所有分支机构的历史记录有效地创建了一个新的存储库,因为下游关注者不再有任何关于 的连续性(每个人都必须重新组织)。但是,如果你想这样做,对于每个分支,找到文件系统中的所有.gitignores,看看提交触及了它们:

  git log`find。 -name .gitignore` 

然后您可以执行 rebase - 交互式上述步骤来改变这些提交。如果提交仅影响 .gitignore,则可以将其删除。但显然,如果提交触及包括.gitignore在内的100个文件,则必须将好坏分开。 另外,如果你知道所有.gitignore文件的路径(检出每个分支并从上面运行 find ),那么你可以通过 filter-branch 执行 github记录等操作。 :

  git filter-branch --force --index-filter \ 
'git rm --cached - -ignore-unmatch .gitignore path / to / other / .gitignore'\
--prune-empty --tag-name-filter cat - --all



他们还提到了一个BFG java工具,但filter-branch应该做你需要的。


I used reposurgeon to convert my svn into a git repository here: (How do I convert an svn repo to git using reposurgeon?).

The problem is, that the converted tags are shown in the log at the place when I created the tag and not at the place of the revision they belong to. In SVN they are shown at the right place in the log where they belong, no matter how long later I created them.

It seems like this has to do something with that reposurgeon adds a commit for .gitignore in each tag that looks like this:

# A simulation of Subversion default ignores, generated by reposurgeon.
*.o
*.lo
...
*.pyo
*.rej
*~
.#*
.*.swp
.DS_store
# The contents of the svn:ignoreproperty on the branch root.
*~
nbproject
*.project

How can I make reposurgeon not create such a commit for gitignore in all tags? And let it create simple tags that don't appear in the timeline as a commit?

The reposurgeon manual sais:

user-generated .gitignore

This message means means reposurgeon has found a .gitignore file in the Subversion repository it is analyzing. This probably happened because somebody was using git-svn as a live gateway, and created ignores which may or may not be congruent with those in the generated .gitignore files that the Subversion ignore properties will be translated into. You'll need to make a policy decision about which set of ignores to use in the conversion, and possibly to delete either the generated .gitignore files or the user-created ones.

But no example how to make that decision. How can I manage this?

解决方案

You'll need to make a policy decision about which set of ignores to use in the conversion, and possibly to delete either the generated .gitignore files or the user-created ones.

Do you have a .gitignore from before the conversion? If so compare it to the one from after. It seems like this policy decision is separate from your "sequence of commits" question, right? Basically, the policy question is just "get a final .gitignore you like". Do what it takes to get there.

In git, the .gitignore file is managed exactly like any other file. So you can say git log .gitignore and see what commits contribute to it. Say that the entire .gitignore file was commited in one block 10 commits ago and you want it parted out. If so, you can do a git rebase --interactive HEAD~11 and edit the commit in question. Do git add --partial .gitignore; git commit for each line you want broken out. Then git rebase --continue to conclude.

If you want the newly itemized commits to each be part of a larger code commit that they correspond to, then you would rebase -i again to shift the order around and squash them with their partner commit. If this sounds like unnecessary work, it probably is. If you can, I would recommend you focus on the integrity of the end state of the repo and less about a perfect expression of history.

Note: I don't understand your use of the term "tag" in this context, since both SVN and git have "tags", but you seem not to be referring to either. Perhaps "ignore line" or "entry" would be clearer.

To purge history in version control is problematic. Changing history on all branches is effectively creating a new repository, since there is no longer continuity to downstream followers for anything (everybody must rebase). But if you want to do it, for each branch, find all the .gitignores in the filesystem and see what commits touched them:

  git log `find . -name .gitignore`

Then you can do the rebase --interactive steps described above to alter those commits. If the commit affects only the .gitignore, you can delete it. But obviously if the commit touches 100 files including the .gitignore, you have to separate out the good from the bad.

Alternatively, if you know the paths of all the .gitignore files (checkout each branch and run the find from above), then you can do something like github has documented with filter-branch:

git filter-branch --force --index-filter      \
 'git rm --cached --ignore-unmatch .gitignore path/to/other/.gitignore'  \
 --prune-empty --tag-name-filter cat -- --all

They also mention a BFG java tool, but filter-branch should do what you need.

这篇关于转换SVN仓库git与reposurgeon没有创建.gitignore文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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