What to do with commit made in a detached head

前端 未结 8 1248

Using git I made something like this

git clone
git checkout {a rev number tree rev before} (here I started to be in a detached head state)
//hacking
git comm         


        
相关标签:
8条回答
  • 2020-11-28 18:14

    Maybe not the best solution, (will rewrite history) but you could also do git reset --hard <hash of detached head commit>.

    0 讨论(0)
  • 2020-11-28 18:19

    An easy fix is to just create a new branch for that commit and checkout to it: git checkout -b <branch-name> <commit-hash>.

    In this way, all the changes you made will be saved in that branch. In case you need to clean up your master branch from leftover commits be sure to run git reset --hard master.

    With this, you will be rewriting your branches so be sure not to disturb anyone with these changes. Be sure to take a look at this article for a better illustration of detached HEAD state.

    0 讨论(0)
提交回复
热议问题