git - 将现有的 Git 存储库迁移到新的支持 Git LFS 的存储库

标签 git github git-rewrite-history bfg-repo-cleaner

我现有的 Github 存储库因 zip 和 tar.gz 文件而变得臃肿,因此我想将其迁移到一个启用 Git LFS 的存储库,该存储库与现有的 Github 存储库分开进行测试,以便现有的 Github repo 未受影响。我遇到了一个很棒的工具 bfg-repo-cleaner https://github.com/rtyley/bfg-repo-cleaner看起来正是我需要的!

我整理了我认为需要执行的步骤,但希望有第二双眼睛来确保这些步骤是正确的。

原始现有 repo 是 https://github.com/username/source.git 启用 Git LFS 的新目标 repo 是 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 以及备份位置添加了额外的 Remote 。我相信 bitbucket 和 gitlab 都像 github 一样支持 Git LFS?

干杯

最佳答案

Git LFS 团队 currently recommends git-lfs-migrate作为首选迁移工具:

git-lfs-migrate is the preferred way now. You shouldn't be needing filter-branch anymore... I hope

关于git - 将现有的 Git 存储库迁移到新的支持 Git LFS 的存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38380782/

相关文章:

svn - 是否存在与大多数版本控制系统(git、svn、hg、cvs,也许是 bzr)兼容的版本控制 gui

Git:恢复删除的远程分支

git - 导出 github 存储库

git - git filter-branch 的正确并行化

git - Rebase git子模块和父仓库

git - 适用于Windows Git Shell(PowerShell)的Github-如何在Git Shell和常规PowerShell之间 “sync settings”

git commit in terminal 打开VIM,但是无法回到终端

git - git pull 后本地分支位于 master 之前

git - 如何修改旧的 Git 提交?

java - Eclipse中的Egit错误: Failure updating tracking ref refs/remotes/origin/5100_<Project_Name>: Missing unknown <commit_id>