Git rebase --abort 使我所有的提交都消失了,有没有办法恢复它们?
Git rebase --abort made all my commits disappear, is there a way to recover them?
我上个月开始了我的项目,到目前为止已经提交了大约 150 次。
我也经常推,我最后一次推是今天早上。所以我的工作并没有完全丢失,但我想知道是否可以进行本地恢复,以恢复我最后一次提交(在推送之后进行)。
事情是这样的:
今天早上,我恢复了 2 天前的一次提交。 AFAIK,事情进展顺利。从那以后,我一直在努力工作。
今天下午,我意识到我最后的 2 次提交可以合并。所以我尝试了git rebase --interactive
。但是 Git 回答:
I wonder if you are in the middle of another rebase. If that is the
case, please try
git rebase (--continue | --abort | --skip)
If that is not the case, please
rm -fr ".git/rebase-merge"
and run me again. I am stopping in case you still have something
valuable there.
我认为我是由于最近的恢复,所以 git rebase --abort
。而我做错了。几乎我所有的提交都消失了,git 日志只显示上个月的前 3 个。我想从那时起我就有一个待处理的 rebase。
有没有办法恢复 rebase --abort ?
感谢阅读和帮助。
编辑:这是 git 状态:
On branch master
Your branch is behind 'origin/master' by 147 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Untracked files:
(use "git add <file>..." to include in what will be committed)
.vscode/
__pycache__/
main.py
venv/
nothing added to commit but untracked files present (use "git add" to track)
编辑:这里是 git reflog(我想回到 f0b2519):
6b634e3 (HEAD -> master) HEAD@{1}: rebase -i (abort): updating HEAD
f0b2519 HEAD@{2}: commit: Add comments in params
da4f6b7 HEAD@{3}: commit: Add comments in params
850ac42 HEAD@{4}: commit: del pygame import in params, adapt main and pygi
3415a2f HEAD@{5}: commit: Put config content in params then delete config
98a8b89 HEAD@{6}: commit: Supress 'if main' in params
72803da (origin/master) HEAD@{7}: checkout: moving from 63cb88ae8d2f1547c7d18882084c06b73d892419 to master
63cb88a HEAD@{8}: checkout: moving from master to branch2
72803da (origin/master) HEAD@{9}: revert: Revert "Move switcher in pgi.press_key()"
3f3ccb6 HEAD@{10}: checkout: moving from branch2 to master
63cb88a HEAD@{11}: checkout: moving from branch2 to branch2
63cb88a HEAD@{12}: revert: Revert "Move switcher in pgi.press_key()"
3f3ccb6 HEAD@{13}: checkout: moving from master to branch2
3f3ccb6 HEAD@{14}: checkout: moving from branch2 to master
3f3ccb6 HEAD@{15}: checkout: moving from master to branch2
3f3ccb6 HEAD@{16}: commit: Update requirements.txt
ccc6845 HEAD@{17}: commit: Edit docstring in pygameinterface
e4632d2 HEAD@{18}: commit: Linting on config and tool
编辑:git reset --hard f0b2519 就像一个魅力,多么令人欣慰!非常感谢大家。
Git reflog 很可能是您的朋友和救星。
Reference logs, or "reflogs", record when the tips of branches and other references were updated in the local repository. Reflogs are useful in various Git commands, to specify the old value of a reference. For example, HEAD@{2} means "where HEAD used to be two moves ago", master@{one.week.ago} means "where master used to point to one week ago in this local repository", and so on. See gitrevisions[7] for more details.
这就是 ohshitgit.com 对 reflog 的看法
You can use this to get back stuff you accidentally deleted, or just to remove some stuff you tried that broke the repo, or to recover after a bad merge, or just to go back to a time when things actually worked.
当我搞砸时,我曾多次使用 reflog。
Whit reflog 你可以回到过去,通过检查 reflog 中的特定点,这 SO answer 可能会澄清更多内容。
我上个月开始了我的项目,到目前为止已经提交了大约 150 次。
我也经常推,我最后一次推是今天早上。所以我的工作并没有完全丢失,但我想知道是否可以进行本地恢复,以恢复我最后一次提交(在推送之后进行)。
事情是这样的:
今天早上,我恢复了 2 天前的一次提交。 AFAIK,事情进展顺利。从那以后,我一直在努力工作。
今天下午,我意识到我最后的 2 次提交可以合并。所以我尝试了
git rebase --interactive
。但是 Git 回答:
I wonder if you are in the middle of another rebase. If that is the
case, please try
git rebase (--continue | --abort | --skip)
If that is not the case, please
rm -fr ".git/rebase-merge"
and run me again. I am stopping in case you still have something
valuable there.
我认为我是由于最近的恢复,所以 git rebase --abort
。而我做错了。几乎我所有的提交都消失了,git 日志只显示上个月的前 3 个。我想从那时起我就有一个待处理的 rebase。
有没有办法恢复 rebase --abort ?
感谢阅读和帮助。
编辑:这是 git 状态:
On branch master
Your branch is behind 'origin/master' by 147 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Untracked files:
(use "git add <file>..." to include in what will be committed)
.vscode/
__pycache__/
main.py
venv/
nothing added to commit but untracked files present (use "git add" to track)
编辑:这里是 git reflog(我想回到 f0b2519):
6b634e3 (HEAD -> master) HEAD@{1}: rebase -i (abort): updating HEAD
f0b2519 HEAD@{2}: commit: Add comments in params
da4f6b7 HEAD@{3}: commit: Add comments in params
850ac42 HEAD@{4}: commit: del pygame import in params, adapt main and pygi
3415a2f HEAD@{5}: commit: Put config content in params then delete config
98a8b89 HEAD@{6}: commit: Supress 'if main' in params
72803da (origin/master) HEAD@{7}: checkout: moving from 63cb88ae8d2f1547c7d18882084c06b73d892419 to master
63cb88a HEAD@{8}: checkout: moving from master to branch2
72803da (origin/master) HEAD@{9}: revert: Revert "Move switcher in pgi.press_key()"
3f3ccb6 HEAD@{10}: checkout: moving from branch2 to master
63cb88a HEAD@{11}: checkout: moving from branch2 to branch2
63cb88a HEAD@{12}: revert: Revert "Move switcher in pgi.press_key()"
3f3ccb6 HEAD@{13}: checkout: moving from master to branch2
3f3ccb6 HEAD@{14}: checkout: moving from branch2 to master
3f3ccb6 HEAD@{15}: checkout: moving from master to branch2
3f3ccb6 HEAD@{16}: commit: Update requirements.txt
ccc6845 HEAD@{17}: commit: Edit docstring in pygameinterface
e4632d2 HEAD@{18}: commit: Linting on config and tool
编辑:git reset --hard f0b2519 就像一个魅力,多么令人欣慰!非常感谢大家。
Git reflog 很可能是您的朋友和救星。
Reference logs, or "reflogs", record when the tips of branches and other references were updated in the local repository. Reflogs are useful in various Git commands, to specify the old value of a reference. For example, HEAD@{2} means "where HEAD used to be two moves ago", master@{one.week.ago} means "where master used to point to one week ago in this local repository", and so on. See gitrevisions[7] for more details.
这就是 ohshitgit.com 对 reflog 的看法
You can use this to get back stuff you accidentally deleted, or just to remove some stuff you tried that broke the repo, or to recover after a bad merge, or just to go back to a time when things actually worked.
当我搞砸时,我曾多次使用 reflog。
Whit reflog 你可以回到过去,通过检查 reflog 中的特定点,这 SO answer 可能会澄清更多内容。