【问题标题】:How to pull somebody else's commits I just rewrited by push --force [duplicate]如何拉别人的提交我刚刚被 push --force [重复]
【发布时间】:2016-01-15 12:29:48
【问题描述】:

这就是我所做的:

git commit -m 'feature 1 implemented'
git push origin feature-branch

..几天后

git commit --amend --no-edit 
git push -f origin feature-branch

然后我意识到功能分支包含其他人推送的提交,我只是搞砸了,因为我忘记了 git pull

我从其他问题中了解到 git push --force 可以轻松撤消

  • 如果您有工作的本地副本
  • 如果你能得到提交 sha

但就我而言,我不知道这些细节,我已经重写了其他提交

我知道我可以要求我的团队成员在不拉动的情况下强制更新,但仍然

有没有办法撤消--force push 和 git 拉这个数据?

【问题讨论】:

  • 如果分支被多个开发人员使用,则使用带有 forse 选项的推送不是一个好主意。

标签: git github git-remote


【解决方案1】:

刚刚在这里How to recover from a git push -force?找到了解决方案

我只需要

git reset --hard origin/feature-branch@{1}

(我可以在 git status 中看到丢失的 commints)

git push -f origin feature-branch

【讨论】:

    猜你喜欢
    • 2016-03-29
    • 2011-05-20
    • 2021-11-19
    • 2013-06-18
    • 2019-09-08
    • 1970-01-01
    • 2013-09-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多