Git跟踪整个主目录。获取错误 - 致命:错误的缺省修订版本'HEAD' [英] Git tracking entire home directory. Get error - fatal: bad default revision 'HEAD'

查看:88
本文介绍了Git跟踪整个主目录。获取错误 - 致命:错误的缺省修订版本'HEAD'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对git完全陌生。我在Mac Terminal工作。



每当我在我的主目录中执行 git status ,所有未跟踪的文件,舞台目录中的文件以及我整个主目录中的提交文件出现。当我在主目录下执行 git log 时,出现以下错误: 'HEAD'



我该如何纠正这个错误?如何让git停止跟踪我的整个主目录的内容而不影响它的当前状态?



在此先感谢,并且我为我的无知道歉。



输入 git status 在主目录中,我得到以下内容:

 〜(master)> Kojo $ git status 
关于分支大师

初始提交

要提交的更改:
(使用git rm --cached< file> ...取消)

新文件:Desktop / Classes / Person.cpp
新文件:Desktop / Classes / Person.h
新文件:Desktop / Classes / Tweeter.cpp
新文件:Desktop / Classes / Tweeter.h
新文件:Documents / AoGPMidterm / xcode / TriMesh.h
新文件:Projects / Testing / Testing / ConditionalClass.cs
新文件:项目/测试/测试/ Lucky_Num.cs
新文件:项目/测试/测试/ NewEnum.cs

未提交的更改:
使用git add / rm< file> ...更新将要提交的内容)
(使用git checkout - < file> ...放弃工作目录中的更改)

已删除:桌面/类/ Person.cpp
已删除:桌面/类/ Person.h
已删除:Desktop / Classes / Tweeter.cpp
已删除:Desktop / Classes /高音单元。 h
修改:Documents / AoGPMidterm / xcode / TriMesh.h
修改:Projects / Testing / Testing / Lucky_Num.cs

未记录文件:
(使用git添加< file> ...以包括将要提交的内容)

.3dequalizer /
.Assimilate /
.CFUserTextEncoding
.MacOSX /
.adobe /
.android /
.appletviewer
.bash_git
.bash_history
.bash_profile
.bashrc
.bashrcecho
.bitrock /
.cache /
.codeintel /
.config /
.cptzzscn


解决方案

造成该错误的原因是因为您尚未进行初始提交。但它看起来像你初始化git仓库在错误的目录。



它看起来像运行 git init 命令在错误的目录中。导航到您最初运行该命令的目录(看起来它是您的主目录)。



运行 ls -la 查看当前目录中的所有文件。你应该看到一个 .git 目录。这包含了git用来跟踪你的存储库工作的所有数据。删除你会回来,就像你之前你跑git。由于您还没有对回购进行任何工作,因此您可以安全地将其移除。



将来您应该运行 git init 专门用于您正在处理的项目的文件夹中。该文件夹中的所有文件和子文件都应该用于您的项目。



如果您刚开始使用git,我强烈建议使用 Pro Git book ,可在线免费获取。


I'm completely new to git. I'm working in Mac Terminal.

Whenever I do a git status in my home directory, all untracked files, files in the stage directory, and committed files in my entire home directory appear. When I do a git log in my home directory, I get the following error:

fatal: bad default revision 'HEAD'

How do I go about correcting this error? How do I get git to stop tracking the contents of my entire home directory without affecting it in its current state?

Thanks in advance, and I apologize for my ignorance. I just do not want to do anything that could be potentially damaging to my home directory.

When I enter git status in the main directory, I get the following:

~ (master) > Kojo$ git status
 On branch master

Initial commit

 Changes to be committed:
   (use "git rm --cached <file>..." to unstage)

    new file:   Desktop/Classes/Person.cpp
    new file:   Desktop/Classes/Person.h
    new file:   Desktop/Classes/Tweeter.cpp
    new file:   Desktop/Classes/Tweeter.h
    new file:   Documents/AoGPMidterm/xcode/TriMesh.h
    new file:   Projects/Testing/Testing/ConditionalClass.cs
    new file:   Projects/Testing/Testing/Lucky_Num.cs
    new file:   Projects/Testing/Testing/NewEnum.cs

 Changes not staged for commit:
   (use "git add/rm <file>..." to update what will be committed)
   (use "git checkout -- <file>..." to discard changes in working directory)

    deleted:    Desktop/Classes/Person.cpp
    deleted:    Desktop/Classes/Person.h
    deleted:    Desktop/Classes/Tweeter.cpp
    deleted:    Desktop/Classes/Tweeter.h
    modified:   Documents/AoGPMidterm/xcode/TriMesh.h
    modified:   Projects/Testing/Testing/Lucky_Num.cs

 Untracked files:
   (use "git add <file>..." to include in what will be committed)

    .3dequalizer/
    .Assimilate/
    .CFUserTextEncoding
    .MacOSX/
    .adobe/
    .android/
    .appletviewer
    .bash_git
    .bash_history
    .bash_profile
    .bashrc
    .bashrcecho
    .bitrock/
    .cache/
    .codeintel/
    .config/
    .cptzzscn

解决方案

The reason for that error is because you haven't made an initial commit. But it also looks like you initialized the git repository in the wrong directory.

It looks like you ran the git init command in the wrong directory. Navigate to the directory you originally ran that command in (Looks like it was your Home Directory).

Run ls -la to see all the files in your current directory. You should see a .git directory. This contains all of data git uses to keep track of your work for a repository. Remove that you'll be back just like you were before you ran git. Since you haven't committed any work to the repo, you can safely remove it.

In the future you should run git init in a folder specifically for the project you are working on. All the files and subfiles in that folder should be for your project.

If you are just getting started using git, I highly recommend the Pro Git book, available for free online.

这篇关于Git跟踪整个主目录。获取错误 - 致命:错误的缺省修订版本'HEAD'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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