[英]How to merge old version to head of a branch in git?
My repository has 2 branches, master and mybranch .我的存储库有 2 个分支, master和mybranch 。 I've commited many times into mybranch , realized that many of my changes were not what I wanted.
我已经多次提交到mybranch ,意识到我的许多更改不是我想要的。
Thus, I did a git checkout
of an old commit on* mybranch* using因此,我对 * mybranch* 上的旧提交进行了
git checkout
使用
git checkout 02c383
I want this old commit to be the HEAD
of mybranch .我希望这个旧提交成为mybranch的
HEAD
。 How do I do this?我该怎么做呢?
When I look at my branches, I see:当我查看我的分支时,我看到:
$ git branch
*(detached from numbershere)
mybranch
master
git checkout mybranch
git reset --hard 02c383
After this, mybranch
will be moved to point to 02c383
.在此之后,
mybranch
将被移动到指向02c383
。
You can reset the current branch to a different commit with您可以将当前分支重置为不同的提交
git reset --hard <ref>
In your example, this translates to在你的例子中,这转化为
git reset --hard 02c383
Beware that当心
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.