我已经通过从我的windows服务器引用https://github.com/git-tfs/git-tfs手动迁移。但是我在TFS有很多仓库。所以我写了一个shell脚本,使用相同的命令,并试图在同一台windows机器上从git bash运行。由于特殊字符,我遇到了错误。
bitbucket_base_url="https://bitbucket.org/fm_ebiz/"
migration_directory="E:\\Migration2"
excel_file="C:/Scripts/Repos.csv"
while IFS=',' read -r repo_path || [[ -n "$repo_path" ]]; do
repo_name=$(basename "$(dirname "$repo_path")")
repo_name=${repo_name,,}
echo "Repo_name: $repo_name"
bitbucket_remote="$bitbucket_base_url$repo_name.git"
echo "Bitbucket_remote: $bitbucket_remote"
mkdir -p "$migration_directory/$repo_name"
git-tfs clone "http://mytfs_url/tfs/ebi" "$repo_path" "$migration_directory\\$repo_name"
echo "Repo_Path: $repo_path"
cd "$migration_directory/$repo_name"
pwd
git remote add bitbucket "$bitbucket_remote"
git pull origin master
if [[ $repo_name == "Release" ]]; then
git push bitbucket master:"$repo_name" --set-upstream
else
git push bitbucket master:"$repo_name"
git push bitbucket "$repo_name:$repo_name" --set-upstream
fi
cd "$migration_directory"
rm -rf "$repo_name"
done < "$excel_file"`
通过运行上述脚本
$ ./migration.sh
Repo_name: appsmgmt
Bitbucket_remote: https://@bitbucket.org/fm_ebiz/<myrepo>.git
TFS repository can not be root and must start with "$/".
You may be able to resolve this problem.
- Try using $/C:/Program Files/Git/TFS_repo path/repo/branch_name
All the logs could be found in the log file: C:\Users\myuser\AppData\Local\git-tfs\git-tfs_log.txt
Repo_Path: $/My TFS repo path/Its printing correctly/
/e/Migration2/<repo>
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
Repo_name: myrepo
Bitbucket_remote: https://bitbucket.org/fm_ebiz/myrepo.git
因此我将git-tfs clone改为cmd,使其作为窗口命令运行,如
cmd.exe /C "git-tfs clone http://mytfs/tfs/ebi \"$repo_path\" \"$migration_directory\\$repo_name\""
其抛出错误“$”无法识别为内部或外部命令、可操作程序或批处理文件。”
1条答案
按热度按时间iqxoj9l91#
我认为原因是bash的一个“坏”行为(从git 2.5开始),其中TFVC路径的“$”被扩展为一个值,因此路径被损坏,git-tfs不知道要克隆什么。
解决方法是在运行“git-tfs”命令之前使用
MSYS_NO_PATHCONV=1
,如下所定义:https://github.com/git-tfs/git-tfs/issues/845#issuecomment-135395001