获取 Subversion -> Git 迁移的 SVN 用户列表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9540757/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:06:25  来源:igfitidea点击:

Getting list of SVN users for Subversion -> Git migration?

gitsvn

提问by xref

I've been looking over a few SVN -> Git migrations and they all mention getting a proper users list before migrating, specifically by using the command:

我一直在查看一些 SVN -> Git 迁移,他们都提到在迁移之前获取正确的用户列表,特别是使用以下命令:

svn log -q | grep -e '^r' | awk 'BEGIN { FS = "|" } ; { print  }' | sort | uniq

I have access to the Ubuntu server hosting the single repository (with 9 projects), but no SVN installation locally. Is it possible to run that command on the server to get the list of usernames? At the moment it just gives back the error:

我可以访问托管单个存储库(有 9 个项目)的 Ubuntu 服务器,但在本地没有安装 SVN。是否可以在服务器上运行该命令来获取用户名列表?目前它只是返回错误:

svn: E155007: '/var/subversion/' is not a working copy

回答by Richard Hansen

Pass the path to the repository as a URL:

将存储库的路径作为 URL 传递:

svn log -q file:///var/subversion | grep -e '^r' | awk 'BEGIN { FS = "|" } ; { print  }' | sort | uniq

By the way, if you need the list of authors in chronological order of first commit (I found it helpful once when converting from svn to git), you can do the following:

顺便说一句,如果您需要按第一次提交的时间顺序排列的作者列表(我发现它在从 svn 转换为 git 时有用一次),您可以执行以下操作:

svn log -q -r 1:HEAD url://to/repo | grep '^r' | awk -F'|' '!x[]++{print}'

回答by Tyler Rafferty

See the instructions below to convert an SVN repository to a git repository

请参阅下面的说明将 SVN 存储库转换为 git 存储库

Note: To ONLY see the list of users run line item 1.

注意:要仅查看用户列表,请运行行项目 1。

CONVERT SVN REPO to GIT REPO

将 SVN 存储库转换为 GIT 存储库

1. Retrieve a list of all Subversion committers

1. 检索所有 Subversion 提交者的列表

 $ svn log -q https://svn.example.com/repository_name | awk -F '|' '/^r/ {sub("^ ", "", ); sub(" $", "", ); print " = "" <"">"}' | sort -u > authors-transform.txt

That will grab all the log messages, pluck out the usernames, eliminate any duplicate usernames, sort the usernames and place them into a "authors-transform.txt” file. Now edit each line in the file. For example, convert:

这将抓取所有日志消息,提取用户名,消除任何重复的用户名,对用户名进行排序并将它们放入“authors-transform.txt”文件中。现在编辑文件中的每一行。例如,转换:

username = username <username>

into this:

进入这个:

 username = Firstname Lastname <[email protected]>

2. Clone the Subversion repository using git-svn

2. 使用 git-svn 克隆 Subversion 存储库

git svn clone [SVN repo URL] --no-metadata -A authors-transform.txt --stdlayout ~/temp

3. Convert svn:ignore properties to .gitignoreIf your svn repo was using svn:ignore properties, you can easily convert this to a .gitignore file using:

3. 将 svn:ignore 属性转换为 .gitignore如果您的 svn repo 使用 svn:ignore 属性,您可以使用以下方法轻松将其转换为 .gitignore 文件:

cd ~/temp
git svn show-ignore > .gitignore
git add .gitignore
git commit -m 'Convert svn:ignore properties to .gitignore.'

4. Push repository to a bare git repositoryFirst, create a bare repository and make its default branch match svn's "trunk” branch name.

4. 将仓库推送到裸git仓库首先,创建一个裸仓库,并使其默认分支与svn的“trunk”分支名称匹配。

git init --bare ~/new-bare.git
cd ~/new-bare.git
git symbolic-ref HEAD refs/heads/trunk

cd ~/temp
git remote add bare ~/new-bare.git
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare

You can now safely delete the ~/temp repository.

您现在可以安全地删除 ~/temp 存储库。

5. Rename "trunk" branch to "master"Your main development branch will be named "trunk” which matches the name it was in Subversion. You'll want to rename it to Git's standard "master” branch using:

5. 将“trunk”分支重命名为“master”你的主要开发分支将被命名为“trunk”,它与它在 Subversion 中的名称相匹配。你需要使用以下命令将它重命名为 Git 的标准“master”分支:

cd ~/new-bare.git
git branch -m trunk master

6. Clean up branches and tagsgit-svn makes all of Subversions tags into very-short branches in Git of the form "tags/name”. You'll want to convert all those branches into actual Git tags using:

6. 清理分支和标签git-svn 使所有 Subversions 标签在 Git 中变成非常短的分支,形式为“标签/名称”。您需要使用以下命令将所有这些分支转换为实际的 Git 标签:

cd ~/new-bare.git
git for-each-ref --format='%(refname)' refs/heads/tags |
cut -d / -f 4 |
while read ref
do
   git tag "$ref" "refs/heads/tags/$ref";
   git branch -D "tags/$ref";
done

7. Move bare repository to central remote repositoryExample of how to move your local bare repository to a gitolite repository:

7. 将裸仓库移动到中央远程仓库如何将本地裸仓库移动到 gitolite 仓库的示例:

mv new-bare.git repository_name.git
tar czvf repository_name.git.tar.gz repository_name.git/
scp repository_name.git.tar.gz remote_host:
ssh remote_host
tar xzvf repository_name.git.tar.gz
sudo chown -R git:staff repository_name.git/
cd repository_name.git/
find . -type f -exec chmod go= {} \;  # remove group and world permissions
find . -type d -exec chmod go= {} \;  # remove group and world permissions
cd ../
mv repository_name.git /Users/git/repositories/

8. Clone new local copy

8. 克隆新的本地副本

mv old-svn-copy old-svn-copy.backup
git clone git@remote_host:repository_name.git

List all unversioned files from your old local svn repository and copy them to the new local git repository:

从旧的本地 svn 存储库中列出所有未版本控制的文件,并将它们复制到新的本地 git 存储库:

cd old-svn-copy.backup
git clean -dXn  # Using this command because the old copy was a git-svn clone
cp example-file.txt ../repository_name/  # copy all files and directories from the list that you need in the new local git repository

You can now move the local svn copy backup to your trash. It might be a good idea not to empty your trash until your sure everything is working correctly.

您现在可以将本地 svn copy 备份移动到您的垃圾箱。在确定一切正常之前不要清空垃圾箱可能是个好主意。

9. Done.

9. 完成。

Source here

来源在这里