想要将我的主人更改为较旧的提交,我该如何做? [英] Want to change my master to an older commit, how can I do this?
本文介绍了想要将我的主人更改为较旧的提交,我该如何做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想回滚到之前的提交,然后发布该代码,然后返回到最新的提交。
I want to rollback to a previous commit, and then publish that code, then go back to the latest commit.
即,所以我的主人正在指向一个较旧的提交版本,所以我可以调整该版本,然后我想回到最初的提交中,我最初是一个。
i.e. so my master is pointing to an older commit version just so I can pulish that version, then I want to go back to the latest commit I was one initially.
如何可以我是这样做的?
How can I do this?
推荐答案
如果您想这样做并将主人恢复到之前的提交状态:
If you want to do this and revert the master to the previous commit:
git checkout master~1 # Checkout previous commit on master
git checkout -b new_master # Create branch for new master
git branch -D master # Delete old master
git branch -mv new_master master # Make new_master master
或者:
Alternatively:
git reset --hard master~1 # Reset current branch to one commit ago on master
这篇关于想要将我的主人更改为较旧的提交,我该如何做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文