简体   繁体   English

如何修改旧的推送提交,然后推送新提交

[英]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.我正在将一个 repo 从 gitlab 迁移到 github,因为我们的 repo 在那里用完了空间,而且我们似乎无法扩展它的大小。 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因此,很自然地,我在 github 上创建了新的 repo,我将 ssh 地址添加到了我本地 repo 实例上的现有遥控器,然后我尝试调用

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.在此过程中,对于添加 .gitignore 和 .gitattributes 文件的第一次提交,一切都完美无缺。

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.然而,在这一点之后,我们从实际项目中推送文件,并且我们已经推送了对于 github 来说太大但对于 gitlab 来说不是太大的文件,因此此时它们不会被表示在 LFS 中进行跟踪.

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.基本上,我想回溯两年的提交,将 LFS 跟踪添加到这些文件中,在添加文件之前插入此提交,然后让它更新剩余的树。

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.我已经尝试将我的 HEAD 重置回那个点,用新的 LFS 数据修改 .gitignore,并在添加文件之前将其推高。 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 Git LFS 提供了一个命令来迁移你的历史git lfs migrate

If your large files are zip, jpg, png如果您的大文件是 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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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