在GIT中失去了我的承诺。你可以不小心删除提交? [英] Lost my commit in GIT. Can you accidentally delete commits?

查看:98
本文介绍了在GIT中失去了我的承诺。你可以不小心删除提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是git gui,而我看不到我的分支。

我知道我今天查了一些东西。

在我完成提交并在分支查看器中对其进行验证后,我更改为较早的分支。
我修改了早期的分支,然后想回到当前的分支,但我再也看不到它了。
任何帮助都会很棒。

解决方案

在回答你的问题时,在大多数情况下,很难失去最近的一次偶然事件。通常情况下,对象(包括提交)只会在 git gc 之后被移除,如果它们不再被任何分支引用,并且它们非常旧(默认90天IIRC) / p>

通常您可以在您的reflog中找到提交。试一下:

  git log -g 


$ b

或:

  git reflog 

如果您能看到它,可能会引用 HEAD @ {n} 其中n是你的 HEAD 自你失去的提交以来发生变化的次数。



你可以创建
$ b

  git branch foundit HEAD @ {n}#用正确的数字替换n 

code>

然后,您可以决定是否需要将它合并到另一个分支或重新绑定它,或者稍后保留分支。 / p>

I'm using git gui and I can't see my branch.

I know I checked something in today.

I changed to an earlier branch after I did my commit and verified it with the branch viewer. I made changes to the earlier branch and then wanted to go back to my current branch, but I can't see it any more. Any help would be great.

解决方案

In answer to your question, in most circumstances it is very hard to lose a recent commit by accident. Usually objects (including commits) only get removed after a git gc if they are no longer referred to by any branch and they are very old (by default 90 days IIRC).

Usually you can find the commit in your reflog. Try either of:

git log -g

or:

git reflog

If you can see it, it probably has a reference of the form HEAD@{n} where n is the number if times your HEAD has changed since the commit you've lost.

You can create a branch for it.

git branch foundit HEAD@{n}  # replace n with the correct number

Then you can decide if you need to merge it in to another branch or rebase it or just keep the branch around for later.

这篇关于在GIT中失去了我的承诺。你可以不小心删除提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆