简体   繁体   中英

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?

Git LFS provide a command to migrate your history git lfs migrate

If your large files are zip, jpg, png

First check the dry run:

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

Then go for it

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM