git head指向老版本_Git - 致命:错误的缺省修订版本'HEAD'&注意:HEAD指向未出生的分支(主)...

I am a newbie to all this and currently taking a class to learn git. However, I was in the process of practicing branching and merging. I had created a new branch and it was switched but my computer started to have issues, which cause me to shut it down and restart. When I return to my work, I returned to this:

>git status

On branch master

Initial commit

Untracked files:

(use "git add ..." to include in what

.gitconfig

AppData/

Contacts/

Creative Cloud Files/

Desktop/

Documents/

Downloads/

Favorites/

Links/

Music/

NTUSER.DAT{9f037fb3-2982-11e3-93f1-b8c

NTUSER.DAT{9f037fb3-2982-11e3-93f1-b8c00000001.regtrans-ms

NTUSER.DAT{9f037fb3-2982-11e3-93f1-b8c00000002.regtrans-ms

ntuser.dat{290469cc-4e2a-11e3-bebb-68500000002.regtrans-ms

I have no idea of what ntuser.dat means and when I run git fsck my return looks like this:

notice: HEAD points to an unborn branch (master)

Checking object directories: 100% (256/256), done.

notice: No default references

When I doing git log, I receive the fatal bad error. I have tried to reset and nothing seems to be working. Can someone please provide me with assistance?

Additionally, I am using a PC, which requires me to use the command prompt for Windows.

解决方案

It looks like this happened...

You ran git init in C:\Users\Sandy.

You may have done other things.

Your computer crashed.

You rebooted.

Whatever you did in #2 was lost.

What you're seeing right now is a Git repository with no commits and a master branch that points to nothing. That's normal after you've created a repository. Here, I can recreate it right now.

$ mkdir foo

$ cd foo

$ git init

Initialized empty Git repository in /Users/schwern/tmp/foo/.git/

$ git log

fatal: bad default revision 'HEAD'

$ git status

On branch master

Initial commit

nothing to commit (create/copy files and use "git add" to track)

$ git fsck

notice: HEAD points to an unborn branch (master)

Checking object directories: 100% (256/256), done.

notice: No default references

All you need to do to fix this is git add and git commit something and proceed as normal.

As for why you're seeing all that junk in git status, Git repositories cover a directory and all subdirectories. If you ran git init in C:\Users\Sandy then the repository will try to track everything in your home directory and all subdirectories. NTUSER.dat is normal Windows administrative files that Windows normally hides from you. Git doesn't care what a file is and shows you everything.

You probably don't want to put your entire home directory in version control. Not that it would hurt anything, it's just not practical. Instead, do as I did and create a new directory and run git init there.

As for your repository in the home directory, just delete it. A Git repository is stored in a .git sub-directory immediately inside your project directory. Delete C:\Users\Sandy\.git\ and you're done. In my example above, it would be foo/.git/.

PS You can't run git init on a file, it has to be in a directory.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值