Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal: Not a git repository (or any of the parent directories): .git on every rails command but git commands works fine

I've got a problem with git and my rails project.

I have set up a github repository and successfully pushed four commits. Every git command i'm trying is working as expected (git status, git add, git commit, git push etc.). But each time I try to execute a rails command (e.g. bundle show, bundle install, rails s, rails generate, rake test etc.) I get following message in my console:

fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git

Every time the message appears on three lines. Sometimes on six lines. The .git folder is in my project and I'm in the correct folder. all rails commands are working as expected. But this annoying message comes with each rails command. I cloned the repository into another folder and created another repository and pushed the code to that new repositiory. The error is in my new folder, too.

I reinitialized my existing Git repository with git init but that changed nothing.

When I set up a fresh rails project and push it into a new repository etc. there are no errors. What could be wrong with my project? Any idea, why this is happening and how to fix this?

I'm working with ruby 1.9.3, rails 3.2.1 and git 1.7.9.

thx to @manojlds I could isolate the problem a little bit more. It's the therubyracer gem. I don't know what exactly is the problem but because I'm on windows I use this special therubyracer gem: https://github.com/hiranpeiris/therubyracer_for_windows. So I will ask the developer of this special gem and will show him the bundler bug. Maybe he will know if it's a problem with his gem or with the bundler. The bundler has an updated pre release. But I can't install the prerelease on windows. So I have to wait and therefore I must live for now with this annoying messages. Or is there a way to disable these messages?

Here is my github issue: https://github.com/hiranpeiris/therubyracer_for_windows/issues/1

like image 491
coderuby Avatar asked Jan 07 '13 15:01

coderuby


People also ask

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

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.

How do I resolve a fatal error in git?

A Git command needs to be run on a specific repository, so this error typically occurs when a Git command is run in a directory that Git doesn't know about. In these cases, the fix is to make sure that you are both working in the correct folder and that you set up your repository right.

Why am I getting 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.

How do I remove a .git from a folder?

Just run the rm command with the -f and -r switch to recursively remove the . git folder and all of the files and folders it contains. This Git repo remove command also allows you to delete the Git repo while allowing all of the other files and folder to remain untouched.


1 Answers

Try running git init in

RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/therubyracer-0.11.0beta1-x86-mingw32.

It will initialize a new empty git repo there.

like image 57
user2158765 Avatar answered Sep 19 '22 12:09

user2158765