Jam*_*sen 52 svn git version-control dvcs
将我的存储库视为SVN存储库,我得到:
svn co http://myrepo/foo/trunk foo
...
foo/
bar/
baz/ -> http://myrepo/baz/trunk
Run Code Online (Sandbox Code Playgroud)
把它作为Git回购处理,我得到:
git svn clone http://myrepo/foo --trunk=trunk --branches=branches --tags=tags
...
foo/
bar/
Run Code Online (Sandbox Code Playgroud)
我可以将baz克隆到其他地方的本地机器并添加一个符号链接,但这只是一个黑客攻击.有没有办法git svn rebase
在更新其他所有内容时自动提取这些更改,就像这样svn up
做?
我刚刚编写了一个简短的脚本,它将所有svn:externals
当前文件检出HEAD
到根目录并将它们从 git 存储库中排除。
将它放置到.git/hooks/post-checkout
,它会在工作树更改时使这些外部结帐保持最新,例如由于git svn rebase
或git-checkout
。
#!/bin/bash
set -eu
revision=$(git svn info | sed -n 's/^Revision: \([1-9][0-9]*\)$/\1/p')
git svn -r${revision} propget svn:externals | head -n-1 | {
while read checkout_args
do
checkout_dirname=$(echo ${checkout_args} | cut -d' ' -f3)
svn checkout ${checkout_args}
if [ -z $(grep ${checkout_dirname} .git/info/exclude) ]
then
echo ${checkout_dirname} >> .git/info/exclude
fi
done
}
Run Code Online (Sandbox Code Playgroud)