Git remote add doesn't work
fatal: Not a git repository (or any of the parent directories): .git
This tells you that the directory you're in is not a git repository. Before you can add remote servers, commit things and so you must have a git repository created.
In a git repository there's a directory (which can be hidden) named .git
. It contains metadata on the repository and all the data regarding the checked files.
To create it type git init
in the directory you wish to have a git repository. Then you could add remote servers and perform operations on it.
Related videos on Youtube
izb
Updated on September 17, 2022Comments
-
izb over 1 year
I'm trying to add a remote server from my git bash prompt with something like:
git remote add origin ssh://myserver.pair.com/usr/home/myname/myrepo.git fatal: Not a git repository (or any of the parent directories): .git
I seem to have ssh set up ok because this...
ssh myserver.pair.com
... logs in just fine without prompting me for my password.
What appears to happen with the remote add is that it doesn't even try to contact the server. It returns with an error instantly, and it doesn't appear to matter what I put for a server name:
git remote add origin ssh://blahblahblah/usr/home/myname/myrepo.git fatal: Not a git repository (or any of the parent directories): .git
Have I misconfigured git somehow?
Technical details: Windows Vista, MsysGit v1.6.4, SSH configured with the file C:\Program Files\Git\etc\ssh\ssh_config
-
izb over 14 yearsThanks :) I actually solved this with a git clone first. +1
-
Bernardo Dal Corno over 4 yearsThis error happened to me even though I'd
git init
. Also solved with git clone