【问题标题】:Get lost commits on GIT在 GIT 上丢失提交
【发布时间】:2013-05-16 13:00:29
【问题描述】:

我和我的合作伙伴正在使用 git 遥控器,并且都拥有对遥控器的写入权限。

他做了一些更改,提交并推送到远程,

我在我的机器上做了一些更改,没有获取/拉取,只是强制推送我的提交。 这反过来又导致我的合作伙伴的提交丢失。

所以我有两个问题:

1.有什么办法可以恢复这些提交?

2。在我推送之后,我的合作伙伴是否也会从他的机器中获取、拉取并删除他所做的更改?

【问题讨论】:

    标签: github git-commit


    【解决方案1】:

    如果您推送的提交覆盖了其他人的代码,但没有拉取; git 会抛出类似这样的错误:

    error: failed to push some refs to 'git@github.com:foo'
    To prevent you from losing history, non-fast-forward updates were rejected
    Merge the remote changes before pushing again.  See the 'non-fast forward'
    section of 'git push --help' for details.
    

    如果您确实覆盖了某些内容,您可以恢复整个 git 存储库。有关示例,请参见此堆栈溢出问题: How do I restore files to previous states in git?

    【讨论】:

    • 我的 BAD 实际上是强制推送
    猜你喜欢
    • 2015-12-12
    • 1970-01-01
    • 2016-08-20
    • 1970-01-01
    • 2022-07-21
    • 2011-01-21
    • 1970-01-01
    • 1970-01-01
    • 2019-06-15
    相关资源
    最近更新 更多