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

标签 .net git visual-studio

我正在尝试使用 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 and commit this undo as well. So you have both the change and the undo commit in history.

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

    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/

    相关文章:

    git - 设置sbt发布到基于git分支的artifactory

    mysql - 从数据库更新模型 | Visual Studio 2019

    .net - 在 Visual Studio 解决方案的上下文中,什么是 Artifact ?

    git - 增加 Github Enterprise 中 protected `master` 分支的代码覆盖率门

    c# - 来自源的延迟绑定(bind)

    Git 打开默认的 git 编辑器而不是 VIM 或任何其他编辑器 (Git Rebase)

    c++ - 如何使用 VS2012 更改解决方案中所有项目的输出目录?

    ruby-on-rails - 对于 Visual Studio 用户来说,最好的 Ruby on Rails 环境是什么?

    c# - 7z格式压缩

    .net - 如何明智地将 Survey 对象与现有 Person 对象相关联,避免 ASP .NET MVC 5 Web 应用程序中 Entity Framework 中的冗余