将现有的Git仓库迁移到新的启用了Git LFS的仓库

3

我的现有Github存储库中包含了许多zip和tar.gz文件,因此我想将其迁移到一个新的启用Git LFS的存储库中,以供测试使用,并使现有的Github存储库保持不变。我发现了一个名为bfg-repo-cleaner的绝妙工具https://github.com/rtyley/bfg-repo-cleaner,看起来正是我需要的!

我整理了一下我认为需要执行的步骤,但希望得到第二个人的确认,以确保这些步骤是正确的。

原始现有存储库为https://github.com/username/source.git,新目标Git LFS启用的存储库为https://github.com/username/destination-lfs.git

pass=PERSONAL_ACCESS_TOKEN
ORIGINAL="https://github.com/username/source.git"
REPONAME_ORIGINAL='source.git'
NEW="https://username:"${pass}"@github.com/username/destination-lfs.git"
REPONAME_NEW='destination-lfs.git'

# setup local work space
mkdir -p /home/workgit
cd /home/workgit

# download bfg
wget -cnv http://repo1.maven.org/maven2/com/madgag/bfg/1.12.12/bfg-1.12.12.jar -O bfg.jar
alias bfg='/bin/java -jar bfg.jar'

# setup local git
git clone --mirror "$ORIGINAL" "$REPONAME_NEW"
cd $REPONAME_NEW
git count-objects -v
git remote rename origin upstream
git remote add origin $NEW
git remote -v
cd ../

time bfg --convert-to-git-lfs '*.{zip,gz,rpm,tgz,xz,bz2,rar,7z,pdf,eot,svg,ttf,woff,woff2}' --no-blob-protection $REPONAME_NEW

cd $REPONAME_NEW
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git count-objects -v
git lfs init
git push --dry-run -u origin master
git push -u origin master

我有没有错过什么?似乎推送也失败了。

git push --dry-run -u origin master                                        
Git LFS: (76 of 43 files) 799.22 MB / 1.43GB                                                                                                                                                                        
Authorization error: https://github-cloud.s3.amazonaws.com/xxxx/media/*****?actor_id=xxxxxx
Check that you have proper access to the repository
error: failed to push some refs to 'https://username:"${pass}"@github.com/username/destination-lfs.git'

此外,原始的 GitHub 存储库还添加了其他远程存储库以备份至 GitLab 和 Bitbucket。我认为像 GitHub 一样,Bitbucket 和 GitLab 也支持 Git LFS,对吗?

祝好


1
BitBucket自2016年7月18日起仅支持LFS:https://dev59.com/questions/5pXfa4cB1Zd3GeqPcEDf#38450750 - VonC
1个回答

6

Git LFS团队目前推荐使用git-lfs-migrate作为首选的迁移工具:

现在git-lfs-migrate是首选方式。您不再需要使用filter-branch...我希望如此。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接