Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal: Not a git repository - Error

Tags:

git

I am new to git. I am just using it for version control onto my local machine. I have initialized my git repo by git init. I have manually added some of the folders that I need to by git add "folder name". There is one particular folder which I am not able to add by using the same command. It is included in the same directory as the others. But I keep getting fatal: Not a git repository "some path". I don't understand what the problem is.

Adding Output

root@CTO:/home/kougaikw/test# git --version
git version 1.8.3.2

root@CTO:/home/kougaikw/test# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#       new file:   main.html
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       .DS_Store
#       css/
#       fonts/
#       images/
#       instance-config.json


root@CTO:/home/kougaikw/test# ls -l
total 36
drwxr-xr-x  2 root root 4096 Apr  5 17:04 css
drwxr-xr-x  2 root root 4096 Apr  5 17:04 fonts
drwxr-xr-x  5 root root 4096 Apr  5 17:04 images
-rw-r--r--  1 root root 1004 Mar 13 08:25 instance-config.json
drwxr-xr-x 10 root root 4096 Apr  5 17:05 js
-rw-r--r--  1 root root  695 Jan  7 08:50 main.html
drwxr-xr-x  8 root root 4096 Apr  5 17:06 mocks
drwxr-xr-x 13 root root 4096 Apr  5 17:07 plugins
drwxr-xr-x 14 root root 4096 Apr  5 17:07 templates

root@CTO:/home/kougaikw/test# git add js
fatal: Not a git repository: js/libs/testfolder/../../../../.git/testfolder/html/js/libs/modules

solution

I had a folder called ".git" inside the directory js/libs/testfolder. Removed it and works fine

like image 935
user3392740 Avatar asked Apr 06 '14 00:04

user3392740


1 Answers

There was a bug in the git which allowed you to add any [.git|GIT] folder under your git project, which was fixed in later git versions.

In your case you added a folder named [.git] in one of your project folders, so git experienced problems handling your repository.

More info about the bug and the fix can be found here

like image 133
CodeWizard Avatar answered Sep 16 '22 11:09

CodeWizard