首页 > 解决方案 > How to modify old, pushed commit, with new commits pushed after it

问题描述

I am in the process of migrating a repo from gitlab to github, as our repo ran out of space there, and it doesn't seem as though we can expand it's size. So, naturally, I created the new repo on github, I added the ssh address to the existing remotes on my local instance of the repo, and I tried calling

git push --mirror github

After letting this run for hours, it fails. After doing research into why this might be, I saw that it may be too large to push up at once, and I should loop through batches of commits and push them up one at a time. During this process, everything works perfectly for the first commit that adds the .gitignore and .gitattributes files.

However, right after this point, we go to push the files from the actual project and already we are pushing files that are too big for github but were not too big for gitlab, so they are not expressed to be tracked in LFS at that point.

Basically, I want to go back two years worth of commits, add in the LFS tracking to these files, insert this commit before the files are added, and then have it update the remaining tree.

I have tried resetting my HEAD back to that point, amending the .gitignore with the new LFS data, and pushing that up before the files are added. However, when trying this route, I now encounter errors when trying to push up the old commits, as it says that the old commits are out of date and need to pull.

Is what I am asking for even possible?

标签: gitgithubgit-commitmigrategit-lfs

解决方案


Git LFS 提供了一个命令来迁移你的历史git lfs migrate

如果您的大文件是 zip、jpg、png

首先检查试运行:

git lfs migrate info --everything --include="*.zip,*.png,*.jpg"

然后去争取

git lfs migrate import --everything --include="*.zip,*.png,*.jpg"

推荐阅读