签出一个旧的提交并维护主分支上的头部? [英] Checking out an old commit and maintaining the head on the master branch?

查看:79
本文介绍了签出一个旧的提交并维护主分支上的头部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前切换到另一个git提交(在同一分支上......实际上,在master分支上!),我正在执行命令

  git checkout ea3d5ed039edd6d4a07cc41bd09eb58edd1f2b3a 

现在,每次我做这个git都会告诉我我现在拥有一个独立的头。我怎么去一个较旧的提交,仍然保持头在同一分支?

解决方案

大部分时间,当我做这个我签​​到一个临时分支:

pre $ git checkout -b temp-branch-name ea3d5ed039edd6d4a07cc41bd09eb58edd1f2b3a

然后,我完成后,我只是删除分支


Currently for switching to another git commit (on the same branch...actually, on the master branch!), I'm executing the command

git checkout ea3d5ed039edd6d4a07cc41bd09eb58edd1f2b3a

Now, every time I do this git tells me that I'm now with a detached head. How do I go to an older commit and still maintain the head on the same branch?

解决方案

Most of the time when I do this I checkout to a temp branch:

git checkout -b temp-branch-name ea3d5ed039edd6d4a07cc41bd09eb58edd1f2b3a

Then after I'm done i just delete the branch

这篇关于签出一个旧的提交并维护主分支上的头部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆