Git分离头问题 [英] Git detached head issue

查看:86
本文介绍了Git分离头问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天阅读了许多与此问题相关的帖子(这里有一个有用的帖子:),但适用于我。

也可以用作在两个分支之间切换的方便快捷键:

  git checkout master 
git checkout branchwithaverylongnamethatyoudontwanttotypeagain
git checkout - #带回master
git checkout - #带回branchwithaverylongnamethatyoudontwanttotypeagain


I've read many posts related to this issue today( one useful one here: Fix a Git detached head? & Why did my Git repo enter a detached HEAD state?).

Today I've been scratching my head. I'm not able to understand how to fix this even after reading those articles.

Yesterday was all ok, I remember having given a checkout command. In the evening I found that Git was not showing any changes even though local changes were present. After researching today I could see now that git status is showing "HEAD detached from 99f040f".

Since then I removed .git folder in my D: (on my Windows 7) and restored .git of 27th July backup. Still not resolved. I tried 25th July version too. But no luck. So I've now restored yesterday's .git version.

I'm pasting the screenshot from gitk. Is there anything I can do to correct this issue?

解决方案

To get back to the last checked-out branch, simply type

git checkout -

Seems a bit under-documented (search for You may also specify in the docs of git checkout), but works for me.
Could also be used as a handy shortcut for switching between two branches:

git checkout master
git checkout branchwithaverylongnamethatyoudontwanttotypeagain
git checkout - # brings back master
git checkout - # brings back branchwithaverylongnamethatyoudontwanttotypeagain

这篇关于Git分离头问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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