git crash during rebase

南楼画角 提交于 2019-12-10 04:08:21

问题


I have rather big amount of file in repository. Thus git sometimes crashes due to out of memory exception during rebasing changes.

E.g.

git checkout feature
git rebase master
(nasty out of memory exception)
.....

So once I got that exception, I tried again rebasing

git rebase master

And it told me that branch feature is up to date. That seems strange, as rebase finished with exception.

Are there any way to avoid oom exception? May be somehow tell git use smaller amount of memory. Could this exception be cause of repository corruption? If it causes corruption are there any way safely roll back changes made during rebase to state that was before git rebase master was called?


回答1:


Try:

git repack -a -f -d

http://git.661346.n2.nabble.com/running-out-of-memory-when-doing-a-clone-of-a-large-repository-td1491051.html




回答2:


You are probably running this on a VM or are storing some large files. Filter branch out large files if you can or bump up the memory :/

Not much else I can add unless I have more info..




回答3:


git rebase $BASE starts by doing git reset --hard $BASE

If it crashes due to out of memory after that, it means you're left with your branch pointer pointing to $BASE instead of the commit it pointed to before.

That's why you're being told that feature is up to date when you git rebase master again, because feature is already pointing to the same commit as master after the out of memory crash.

To reset your branch back to the original commit you were on before, run

git reset --hard HEAD@{1}`.

Or if you've done other work on the branch after the crash, run git reflog to find the original commit.

See also Undoing a git rebase


After you got your branch back to the original commit, you can try

git rebase -m master

which will try a different rebase strategy that probably uses less memory if you have large binary files.



来源:https://stackoverflow.com/questions/7692944/git-crash-during-rebase

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!