Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Not a git repository"

Tags:

git

I am trying to use a program that uses git as the backing store (I am new to git). On initialization, this program does a:

"git" "--bare" "rev-parse" "refs/heads/index"

Which results in:

fatal: Not a git repository: '/home/david/blog.git'

I followed this tutorial, git init, git add test.txt and git commit. The repo seems to behave properly when (in the correct directory) I do (for example):

$ git status

What is rev-parse doing and what do I have to do to my repo to make it work?

like image 621
user147714 Avatar asked Nov 14 '09 14:11

user147714


People also ask

What is not a git repository?

The “not a git repository” error is common. The cause is running a Git command in the wrong folder or running a Git command before initializing a Git repository. Now you're ready to solve the “not a git repository” error like an expert developer!

How do I fix a git error not a repository?

Check that you correctly created the repo. If the directory doesn't contain a . git repo, use git init to properly initialize the repo or clone an existing repo. Make sure your HEAD file contains the correct information on your current branch.

How do you fix not a git repository or any of the parent directories?

For the second situation, you need to initialize the Git repository in your project folder. To do so, you need to navigate to the correct folder and then run the command git init , which will create a new empty Git repository or reinitialize an existing one.

What makes a git repository?

A Git repository tracks and saves the history of all changes made to the files in a Git project. It saves this data in a directory called . git , also known as the repository folder. Git uses a version control system to track all changes made to the project and save them in the repository.


1 Answers

If git status is working then you must be in a non-bare repository with a working tree. git status requires a working tree.

If the program is running git --bare ... then it expects the given directory to be a bare git repository, i.e. with not working directory.

The naming convention of reponame.git is usually reserved for bare repositores and non-bare repositories usually use a directory name of reponame and contain a .git subdirectory.

If /home/david/blog.git is actually a non-bare repository then it will have a .git subdirectory. If this is the case you can probably point the program at /home/david/blog.git/.git but I can't help feeling that it would be safer to point it at a truly bare repository. What program is it and what were the instructions for initializing its data store? `

like image 170
CB Bailey Avatar answered Oct 23 '22 01:10

CB Bailey