26

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?

romainberger
  • 4,563
  • 2
  • 35
  • 51
  • 1
    Is the path on the remote server really `/my_repo.git`? Or is it in your home directory or something? – tpg2114 Apr 30 '12 at 23:11
  • I wasn't sure so I tried with `my_repo.git`and `/my_repo.git`and nothing works – romainberger Apr 30 '12 at 23:18
  • 3
    On your server, go to the directory that is the repository and type `pwd`. The output is the full path of the repository, make sure you use that. – tpg2114 May 01 '12 at 00:30
  • 1
    Where is the repository installed on your server? Are you connecting to the remote server using `ssh`? Have you verified that `ssh` functionality is working outside of `git`? How did you connect your local repository to the remote repository -- did you use `git clone`? What command did you type exactly? Did you use `git remote add`? Again, what was the exact command? Can you show us your full `git push` command line (that is, are you typing anything other than simply `git push`)? – larsks May 01 '12 at 00:35
  • thanks @tpg2114 for the `pwd` command I did not know how to get the full path – romainberger May 01 '12 at 08:27

4 Answers4

58

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)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks it worked, it was indeed the full path that was missing. The `stdin: is not a tty`error is still here though, I will try to fix it. – romainberger May 01 '12 at 08:26
  • 5
    It is also possible to use ~ in the path when you refer to a project in your home directory, e.g. `ssh://name@server/~/myproj/` – Timmos Jul 20 '15 at 08:27
  • yah, it work's for me too. thank you from saving me from frustating – Jamaluddin Rumi Dec 10 '17 at 05:03
  • 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) – Abpostman1 Dec 22 '22 at 11:59
  • @Abpostman1 Thank you for your feedback. I have included your comment in the answer for more visibility. – VonC Dec 22 '22 at 12:04
11

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

user3353537
  • 161
  • 2
  • 3
1

Or, you can simply use:

git clone user@server:/full/path/to/your/directory
Lucky
  • 16,787
  • 19
  • 117
  • 151
dushshantha
  • 437
  • 5
  • 10
1

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...)

Artfaith
  • 1,183
  • 4
  • 19
  • 29