Search code examples
gitgit-init

"Reinitialized existing Git repository" message in completely new directory


When running the git init command in a completely new and empty directory, I get this error message:

Reinitialized existing Git repository in /<just path stuff>/gittests/completelyEmptyDirectory/.git/

What is going on here? The only commands being run are mkdir completelyEmptyDirectory, going into that directory, and then running git init.


Solution

  • After investigating further the reason this was happening is because in my .gitconfig the [init] section was pointing to my .git_templates folder. The templates folder contains only one file called HEAD that had this:

    ref: refs/heads/main
    

    Not sure exactly why this was causing the error above.

    Replacing that line with:

    defaultBranch = main
    

    resolved the issue. Still would like to figure out why the [init] was set to point to the .git_templates in the first place.