2

我想将项目从 SVN 迁移到 Git 并保留历史记录。

但由于 SVN 存储库中有一些包含生产密码和其他敏感数据的配置文件,我想从迁移的历史记录中排除这几个文件。

我该怎么做呢?

4

2 回答 2

3

最简单的解决方案是将您的 SVN 存储库迁移到 本地计算机上的Git ,然后在将迁移的历史记录推送到远程存储库之前删除包含敏感数据的文件。

例如:

# Migrate the SVN project into a local repo
git svn clone svn://server/svnroot \
    --authors-file=authors.txt \
    --no-metadata \
    -s your_project

cd your_project   

# Remove the 'passwd.txt' file from the history of the local repo
git filter-branch --force --index-filter \
    'git rm --cached --ignore-unmatch passwd.txt' \
    --prune-empty --tag-name-filter cat -- --all

只要您不将本地 Git 存储库推送到远程位置,您就可以使用git filter-branch. 删除文件后,可以安全地在您想要的任何地方发布 repo。

另一种解决方案git filter-branch是使用名为BFG Repo-Cleaner的工具,该工具使用自己的 - 据说速度更快- 实现从 Git 存储库的历史记录中删除文件。对于10.000 次提交,可能值得考虑,因为 的性能git filter-branch将至少与要处理的提交数呈线性关系。

于 2015-09-24T12:27:15.123 回答
-2

基本上你有两种策略

  1. 先清理SVN,再迁移到GIT
  2. 先迁移,然后在 GIT 中清理

先清理SVN,再迁移到GIT

根据SVN:

“(...)您唯一的办法是 svnadmin 转储您的存储库,然后通过 svndumpfilter(不包括错误路径)将转储文件传送到 svnadmin 加载命令(...)”

http://subversion.apache.org/faq.html#removal

先迁移,然后在 GIT 中清理

Github 对此有一篇很好的文章

https://help.github.com/articles/remove-sensitive-data/

于 2015-09-24T12:25:19.207 回答