Checking out an old commit and maintaining the head on the master branch?

后端 未结 6 1721
名媛妹妹
名媛妹妹 2020-12-22 16:29

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

git checkout ea3d5ed039edd6d         


        
6条回答
  •  眼角桃花
    2020-12-22 17:11

    If you simply want to return to an earlier commit to play with it without making any changes, you can do

    git co 
    

    you'll will be on a branch called "(no branch)" after this command.

    Confirm this by

    git br
    

    After you've played with this previously committed code, you can switch to the branch you were on by

    git co 
    

    The "(no branch)" will be deleted automatically. This way you don't need to create a temporary branch.

提交回复
热议问题