如何同步到 GitHub 中之前的变更列表?

发布于 2024-10-10 18:03:36 字数 392 浏览 3 评论 0原文

我来自 Perforce 世界,所以我在这里的语言将是 Perforce 语言,但我正在尝试使用 GitHub,但发生了一些可怕的事情。我使用命令:

git reset --hard
(and)
git clean -f -x -d
(and then)
git fetch

尝试恢复我刚刚编写的一些代码。

我没有恢复我的代码,而是所有被修改的文件都从服务器和本地计算机上删除了。
不幸的是,我的大部分代码都在一个源文件中,并且由于我修改了该文件,它已经从服务器和本地计算机上消失了。

有人可以给我 GitHub 命令来同步到旧版本的代码吗?恐怕这是我拿回源代码的唯一方法......!

有谁知道我在这里做错了什么?

谢谢 -西蒙

I come from the Perforce world, so my language here is going to be Perforce speak, but I am trying to use GitHUB and something terrible has happened. I used the commands:

git reset --hard
(and)
git clean -f -x -d
(and then)
git fetch

to attempt to revert some code I had just written.

Instead of reverting my code, all that happened to me was all of my files that were modified got deleted off the server AND off my local machine.
Unfortunately most of my code was in a single source file, and since I had modified that file it has vanished from existence, both off the server AND off my local machine.

Could someone please give me the GitHub command to sync to an older revision of the code? I'm afraid this is the only way I'm going to get my source code back...!

Does anyone know what I have done wrong here?

Thanks
-Simon

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

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

发布评论

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

评论(1

执手闯天涯 2024-10-17 18:03:36

使用您列出的命令,服务器上应该不会发生任何事情。即使您推送了不想要的更改(例如,删除了文件的更改),所有历史记录都应该保留在服务器上。

您是否尝试过再次简单地克隆存储库?这可能是确保本地 git 克隆处于正常状态的最简单方法。之后,查看日志中的文件。

如果它仍然不存在,那么您所做的事情一定比您在原始问题中指出的要多。

Nothing should have happened on the server with the commands you listed. Even if you pushed a change you didn't want (e.g., one that deleted a file), all the history should have been preserved on the server.

Have you tried simply cloning the repository again? That might be the simplest way to ensure that your local git clone is in a sane state. After that, look through the log for the file.

If it's still not there, you must have done more than you indicated in your original question.

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