romainberger
romainberger

Reputation: 4558

Git "does not appear to be a git repository"

I am trying to install git on a server and have some problem when I try to perform the first push. I successfully installed git on the server, created the repository locally and on the server but when I try to make the first push I get this message:

stdin: is not a tty
fatal: '/my_repo.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

I googled it and followed everything I could find but nothing worked. What could be wrong?

Upvotes: 26

Views: 84390

Answers (4)

VonC
VonC

Reputation: 1328982

I will assume you are using ssh to clone your repo.

That means you need the full path of the repo on the server in your ssh address:

git clone ssh://sshuser@serverIP/full/absolute/path/to/my_repo

Note: if your 'my_repo' is a bare one (to allow pushing), that would be:

git clone ssh://sshuser@serverIP/full/absolute/path/to/my_repo.git

The stdin: is not a tty simply means that in the .bashrc of the sshuser account, there is something expecting an input.


Abpostman1 adds in the comments:

Had this issue because I was trying to push in a --bare repo non empty.
Even if it was exactly the same files, I had the same error message: "Not git repository"

I had to backup my /httpdocs remote folder, create an empty new /httpdocs folder, do again git init --bare and re-push from local.

My remote address : url = ssh://magento@magento/home/magento/httpdocs (with a private/public key in both sides)

Upvotes: 59

Serious Angel
Serious Angel

Reputation: 1567

A non-jailed/non-chrooted git user may also be the issue source, and setting the user's home directory (~/) may also help. For example, change:

git clone -- 'ssh://user@host:port/dir/repo.git';

to

git clone -- 'ssh://user@host:port/~/dir/repo.git';

Related: Git "does not appear to be a git repository" (It is also possible to use ~ in the path when you...)

Upvotes: 1

dushshantha
dushshantha

Reputation: 447

Or, you can simply use:

git clone user@server:/full/path/to/your/directory

Upvotes: 1

user3353537
user3353537

Reputation: 161

May be you forgot to run git --bare init on the remote folder That was my problem

Upvotes: 11

Related Questions