2

我在 master 上犯了错误并提交了开发更改,并将它们推送到上游。从远程仓库中撤销这些更改的最佳方法是什么,但在本地保留一个分支以供以后合并到 master 中?

4

1 回答 1

3

您只需要按顺序排列分支,然后进行强制推送:

git checkout master        # though you're probably already there
# create the branch you should've committed to instead of master
git branch local-changes
# put master back where it belongs
git reset --hard <commit-master-should-be-at>
# and push it to origin!
git push -f

关于这将如何与从上游回购中拉出的任何人一起搞砸的所有常见警告都适用!

于 2011-01-17T20:48:15.843 回答