gpt4 book ai didi

.net - 在 Visual Studio 中执行 git Reset 后如何摆脱传入的提交? (删除远程提交)

转载 作者:行者123 更新时间:2023-12-03 23:37:55 25 4
gpt4 key购买 nike

我正在尝试使用 Git 下的 Visual Studio 团队资源管理器。但是,当我点击 enter image description here
这,我可以回到我以前的版本,它不能,因为有传入的提交再次回到最新的错误版本......
enter image description here
我尝试单击还原并不能帮助我再次返回到以前的版本。任何人都可以帮助如何在没有传入提交的情况下返回到以前的版本吗?

最佳答案

您需要enable force push然后用力推。
为此,在进行重置(删除更改)后:

  • 转到团队资源管理器 → 设置 → Git → 全局设置并检查 Enable push --force然后点击 Update按钮。
  • 转到团队资源管理器 → 分支 → 右键单击​​您的本地分支并选择 Push
  • 将出现一个消息框,显示一条警告,询问您是否要覆盖远程提交?选择 Yes .

  • Warning

    Usually you need to revert changes which simply means undo changes andcommit this undo as well. So you have both the change and the undocommit in history.

    But sometimes for some reason, you want to get rid of few last commitswithout having them in remote history (WARNING). So you can resetthose few commits and delete changes. Now your local branch is behindthe remote branch and there are several incoming commits. Then you cando a force push to overwrite remote commit history by your localhistory.

    Do this carefully, just when you understand what you are doing, is overwriting remote history. Don't do it on a branch which is shared between multiple people.

    关于.net - 在 Visual Studio 中执行 git Reset 后如何摆脱传入的提交? (删除远程提交),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45295374/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com