我犯了错误,在主服务器上提交了开发更改,并将它们推向上游。从远程存储库撤消这些更改,但在本地保留分支以便稍后 merge 到主服务器中的最佳方法是什么?
最佳答案
您只需按顺序排列分支,然后进行强制推送:
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
所有关于这将如何影响从上游存储库中提取的人的常见警告都适用!
关于git rebase 远程,但在本地保留更改以供以后提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4717700/