Git tracking entire home directory. Get error - fatal: bad default revision 'HEAD'

前端 未结 2 1102
猫巷女王i
猫巷女王i 2020-12-10 05:22

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 direc

相关标签:
2条回答
  • 2020-12-10 05:56

    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.

    0 讨论(0)
  • 2020-12-10 05:57

    I'm not sure if this is what happened in your case, but you can get the error message from git log

    fatal: bad default revision 'HEAD'

    if you just made your repo, and you haven't made any commits in it yet. If this is your case, then simply add your files, commit them, and do the log again:

    $ git add "*"
    $ git commit -m "Your commit message"
    $ git log
    
    0 讨论(0)
提交回复
热议问题