用旧版本的 git repo 覆盖 git repo,游戏结束了吗?

发布于 2024-11-02 20:31:58 字数 215 浏览 4 评论 0原文

我完全失去了所有的承诺吗?我知道这是愚蠢的,为此我很抱歉,但这是一个无心的错误,没有正确考虑工作流程。

编辑

覆盖是手动拖放,没有输入终端命令。

我在Mac上。

我有时间机器,并且可以检索我的旧新存储库(如果你知道我的意思,我的头正在融化),但是我可以合并它们(已经进行了更改,截止日期查看)或者我应该恢复备份整体?

Have I totally lost all my commits? I know it was dumb, and for that I am sorry, but it was an innocent mistake, not thinking a workflow through properly.

EDIT

the overwrite was a manual drag and drop, no terminal commands entered.

I am on a mac.

I have time machine, and can retrieve my old new repo (if you know what I mean, my head is melting), but can I merge them (have have since made changes, deadline looking) or should I just reinstate the backup in it's entirety?

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

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

发布评论

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

评论(3

风吹短裙飘 2024-11-09 20:31:58

好吧,这会很麻烦,但你的提交可能仍然存在......

运行 git fsck --full (可能需要一段时间)——它将列出所有悬空的 blob/树/提交。使用 git log/git show/gitk 检查每个危险的提交。当您找到分支的头提交时,请使用 gitbranch重新创建分支。 <提交的 sha1> (您必须记住您的旧分支名称),


因为您使用时间机器恢复了旧存储库状态并且旧存储库现在位于桌面上,最简单的事情就是添加一个新的远程,然后获取远程提交:

git remote add old-repo /path/to/your/desktop/old-dir/.git
# sorry, no clue what the actual path might be on mac systems (~/Desktop/…?)
git fetch old-repo

之后,您将拥有旧存储库中的所有分支,作为 old-repo/branchname 。要合并它们,只需发出 git merge old-repo/branch 命令即可。这只是基本的 git fu,用于将存储库设置为附加远程并合并其更改(这里没有魔法,继续前进)

well, it will be cumbersome, but your commits will probably still be there …

run git fsck --full (might take a while) – it will list all dangling blobs/trees/commits. inspect each danging commit with git log/git show/gitk. when you find a head commit of a branch, recreate the branch with git branch <branchname> <sha1 of commit> (you have to remember your old branch names)


since you recovered your old repository state using time machine and have your old repository now on your desktop, simplest thing to do for you would be adding a new remote and then fetching the remote commits:

git remote add old-repo /path/to/your/desktop/old-dir/.git
# sorry, no clue what the actual path might be on mac systems (~/Desktop/…?)
git fetch old-repo

after that you will have all branches from your old repository available as old-repo/branchname. to merge them simply issue a git merge old-repo/branch command. this is mere basic git fu to set up a repository as an additional remote and merge its changes (no magic going on here, move along)

满身野味 2024-11-09 20:31:58

窗户? Linux?

如果是 Windows,您可以尝试使用恢复工具或可以直接读取磁盘的十六进制编辑器来恢复文件。在 Linux 上,我不知道。

但是,是的,如果你没有备份......那是你的错! =)

Windows ? Linux ?

If its Windows you can attempt recovering your files using recovery tools or a hex editor that can directly read the disk. On Linux, I don't know.

But yeah if you have no backups... it's your fault ! =)

叹沉浮 2024-11-09 20:31:58

有时,只是有时你会很幸运。在 Windows 7 上,打开文件夹的属性并单击“以前的版本”。

当我看起来好像失去了一切时,我很幸运地找到了使用该技术的旧 iPhone 备份!

Sometimes, just sometimes you can be lucky. On windows 7, open the properties of the folder and click "Previous Versions".

I was lucky enough to find an old iPhone backup using that technique when it looked like i'd lost all!!

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