In Git, how do you see and manage commits that aren't in a branch?

前端 未结 3 891
长发绾君心
长发绾君心 2021-01-22 17:39

A commit isn\'t necessarily in a branch, so how do you see and manage these commits? Also, is it possible to look at these commits from gitk?

Thanks a lot!

PS: j

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-22 18:25

    This situation is called a detached HEAD. Normally tools (such as gitk) won't show you commits that aren't reachable by a symbolic branch name.

    To get your commit back, you can use git reflog to show a log of all recent activity, including your detached HEAD. When you find it, you can use its commit ID with git checkout to get back to it. If you find that it's valuable, you may want to give the branch a name at that point.

提交回复
热议问题