GIT 说我在仓库中没有提交——如何恢复?

发布于 2024-12-24 04:06:20 字数 528 浏览 6 评论 0原文

使用Win7,64位。

我使用 GitExtensions GUI,它已经运行良好 3 个月了。今天我做了一次提交,立即推送到我的服务器存储库,然后关闭。当我当天晚些时候重新启动并尝试进行另一次(本地)提交时,GitExtensions 告诉我,我从未提交过该存储库,并显示了 119 个有更改的文件。

显然有些东西被炸了,所以我的第一个想法是从我的服务器存储库中拉取。你猜怎么着?服务器存储库还显示我从未承诺过它。

所以我的下一个想法是 GitExtensions 在骗我。所以我转向 Tortoise GIT 并做了一个“查看日志”。你猜怎么着? GitExtensions 没有说谎。 Tortoise GIT 还表明我从未承诺过我的仓库。

当我实际浏览存储库时,我可以看到所有具有合理时间戳的对象文件,涵盖了我从事该项目的 3 个月时间。

我怎样才能让 GIT 恢复并意识到我还有 3 个月的提交?我见过的唯一文章是关于如何恢复单个丢失的提交,这些提交需要使用较早的提交作为起点。显然这对我没有帮助,因为我看不到任何提交。

感谢您的帮助。

Using Win7, 64-bit.

I use the GitExtensions GUI, which has been working fine for 3 months. Today I did a commit, immediately pushed to my server repo, and shut down. When I powered back up later in the day and tried to do another (local) commit, GitExtensions told me that I have NEVER committed to that repo and showed 119 files with changes.

Obviously something got fried, so my first thought was to do a pull from my server repo. Guess what? The server repo is also showing that I have NEVER committed to it.

So then my next thought was GitExtensions is lying to me. So I moved over to Tortoise GIT and did a "View Log". Guess what? GitExtensions isn't lying. Tortoise GIT also shows that I have NEVER committed to my repo.

When I physically browse in the repo, I can see all the object files with reasonable-looking timestamps covering the 3 months I've been working on this project.

How can I get GIT to recover and realize that I have 3 months of commits STILL IN THERE? The only articles I've seen are on how to recover individual lost commits that need to make use of an earlier commit as a starting point. Obviously that's not going to help me since I can't see ANY commits.

Thanks for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

他是夢罘是命 2024-12-31 04:06:20

首先,备份您的存储库,以便任何失败的尝试修复都不会使其损坏更严重。

git fsck 可以帮助查找并修复存储库中的错误。

git reflog 可以帮助您识别孤立的提交并重建历史记录。

关于 "bad default revision" 错误的答案可能会有所帮助。

如果 fsck 对您没有任何帮助,我的第一个想法是尝试将远程存储库的 HEAD 重置回一次提交,然后尝试重新克隆。

First, back up your repository so that any attempted fixes that fail don't corrupt it worse.

git fsck can help find and fix errors in the repository.

git reflog can help you identify orphaned commits and reconstruct the history.

This answer on the "bad default revision" error may help.

If fsck does nothing for you, my first thought would be to try to reset the remote repository's HEAD back one commit and then try a re-clone.

℡Ms空城旧梦 2024-12-31 04:06:20

检查“git log master”或任何其他分支的内容。如果有效,您可以使用“git bundle”显式导出提交和所有相关对象。冲洗并重复询问 .git/refs 中的其他分支。

最好进入命令行来修复此问题。下载最新的 msysgit。

Check what you get for "git log master" or any other branch. If that works, you can use "git bundle" to explicitly export commits and all related objects. Rinse and repeat for ask other branches in .git/refs.

It would probably be best to drop down to the command line to get this fixed. Download the latest msysgit.

薄荷港 2024-12-31 04:06:20

.git 文件夹还在吗?如果是的话,那就是 git 存储所有信息的地方。如果没有,那就没有什么可收回的了。如果没有,那么你的本地 git 就消失了。如果 .git 仍然存在,请尝试运行 git log 并查看它显示的内容。

如果您的 .git 文件夹消失了,那么您应该能够从服务器进行“新”克隆以检索所有内容。

Is the .git folder still in there? If it is that is where git stores all it's information. If not, then there is nothing to get back. If not, then your local git is gone. If you .git is still there, try running git log and see what it shows.

If your .git folder is gone, then you should be able to do a "new" clone from your server to retrieve everything.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文