简体   繁体   English

通过 PR 将远程分支恢复到特定提交

[英]Reverting remote branch through PR to a specific commit

Basically I have a remote master branch that I do not have direct push access to.基本上我有一个远程主分支,我没有直接推送访问权限。 I've identified a commit say x commits ago that I want to revert the remote branch to.我已经确定了一个提交说 x commits ago 我想将远程分支恢复到。 Is there a simple way to do this without having to revert all the previous commits before x?有没有一种简单的方法可以做到这一点,而不必还原 x 之前的所有先前提交?

I've attempted:我尝试过:

git checkout -b A_DEV_BRANCH
git reset --hard COMMIT_SHA_X
git add .
git push origin A_DEV_BRANCH

But that reports 0 changes through the pull request, and doesn't appear to remove the commits since X, feel like I might be missing something simple here?但是通过拉取请求报告了 0 个更改,并且似乎没有删除自 X 以来的提交,感觉我可能在这里遗漏了一些简单的东西?

The easiest way to do this was to track down the specific commit (y) that results in x being present in the remote branch then revert it using git revert y and committing the result back to master.最简单的方法是跟踪导致 x 出现在远程分支中的特定提交 (y),然后使用git revert y将其git revert y并将结果提交回 master。

To do what I wanted to do is possible using git reset but would involve re-writing history and potentially causing problems for people who based their work off of in between commits to the remote.使用git reset做我想做的事情是可能的,但会涉及重写历史记录,并且可能会给那些将工作放在远程提交之间的人造成问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM