4

I have a NAS on which I created a remote repository with the command git --bare init and I then clone this repository on my machine with the command git clone ssh://ID@PathToDistantRepo and it tells me that I have clone an empty repository.

So far I have no problem.

I add things, I make my commit, everything is fine, no error and the commit is present in the history.

But when I do git push origin master it asks me three times for the password of the ssh connection and then nothing. I let it run for half an hour and the prompt remains frozen without anything indicated.

If I add the "-verbose" option, nothing new.

If I run the git remote show origin It ask me the password and then show me this :

* remote origin
  Fetch URL: ssh://ID@PathToDistantRepo
  Push  URL: ssh://ID@PathToDistantRepo
  HEAD branch: (unknown)
  Local branch configured for 'git pull':
    master merges with remote master

I did not give you the exact URLs but they are good and I search the net, but I must not know how to put the right keywords because I can not find anything.

Thank you in advance for your help.

Daemon Painter
  • 3,208
  • 3
  • 29
  • 44
Varden
  • 101
  • 5
  • Try `git push -u origin --all` for the first time. The other debugging option I would try is to create a bare directory on a local folder (not on the NAS), use the same commands and see if that works as a test. Also - not sure, but since you have to SSH over to the NAS, then the server, I assume, has it's own separate git install? But I'm not sure, does it need a service running to handle the push request locally? I'm not sure how that handoff happens... – LightCC Jul 28 '20 at 19:02
  • 1
    Perhaps this is related: https://stackoverflow.com/a/32792843/4865273 Restarting ssh agent and sshd server apparently solved the issue. – tomptz Jul 28 '20 at 19:21
  • I have tested `git push -u origin --all` but nothing new. before looking how to restart the ssh agent I tried creating a new distant repo on the same devices but with close to nothing in it, juste a folder and a text file and the push command work perfectly. The folder I am trying to push is heavy "1.05Go" because it's a Unity project. But I have already doing this and it worked. I will let the command prompt work a long time in case it's just very busy and say nothing until all the files are scan or I don't know. – Varden Jul 29 '20 at 08:13
  • If you problem is specific to large commits, try increasing the postBuffer. I have updated my answer below. – tomptz Jul 29 '20 at 08:46

2 Answers2

0

Based on https://stackoverflow.com/a/32792843/4865273 restarting your SSH agent and sshd server may help.

Assuming you are on a Linux system, restart your SSH agent as follows.

First, find the agent PID:

eval "$(ssh-agent -s)"

This returns the PID number (e.g., 1234). Use this number in the next command to kill the agent:

kill -9 1234

To restart the sshd service, see https://www.cyberciti.biz/faq/howto-restart-ssh/ If you use Ubuntu (systemd), you can simply execute: sudo systemctl restart ssh

If the problem specifically occurs when pushing large commits, try increasing the postBuffer:

git config --global http.postBuffer 2097152000 

This is known to solve similar issues, see https://stackoverflow.com/a/26663047/4865273

As you are asked 3 times to enter the SSH password, another solution may be to set up SSH keys for authentication instead of using a password. To do so, see https://www.cyberciti.biz/faq/how-to-set-up-ssh-keys-on-linux-unix

tomptz
  • 71
  • 5
  • I'm on Windows 10 and here are my results : I found the SSH services and they weren't even started when I just used them to do the tests successfully on a new repository. So I started them but it didn't change anything. – Varden Jul 29 '20 at 09:51
  • I run `git config --global http.postBuffer 2097152000 ` but it did'nt change anything. Regarding the fact that I am asked three times for the password, the problem is that in normal times he asks for it once and everything is fine and I don't mind. But there three times is not normal and nothing more works ... The folder to commit is heavy but fills many small files, so I expected a long push but it doesn't even seem to start ... I will try to recreate the repository and make several small commits because at creation there is a lot, but afterwards it will only be small pushes – Varden Jul 29 '20 at 09:51
  • The sshd service needs to be restarted on the NAS side (this is the SSH server to which you connect from your windows machine). Have you tried that? – tomptz Jul 29 '20 at 09:57
0

after many tests the problem is most likely due to the fact that Git is not made to handle many large files and therefore putting the whole project in the repository is not a good method. It's the Unity packages that are causing the problem.

I would have to master more how Git works to have a more targeted and granular use of it to put only what is useful to me and I would do it another time.

Thank you all for your help, it will at least have given me some knowledge and the start of a better understanding of Git and SSH.

Varden
  • 101
  • 5
  • You may want to consider git-lfs, an extension to Git specifically targetting large file storage. See https://git-lfs.github.com/ – tomptz Jul 29 '20 at 16:23