1

I want to merge my local branch with the branch on my server. On my local computer I navigate to my project folder and then type:

git remote add origin ssh://myuser@myhost:22/html/myproject

But I get the error message:

external Repository origin already exists

So I tried to use another branch name:

git remote add testbranch ssh://myhost@myuser:22/html/myproject

and then

git push testbranch master

and then I get the error message:

fatal: '/myproject' does not appear to be a git repository fatal: Could not read from Remote-Repository. Please ensure that the correct access permissions exist and the repository exists.

I checked /myproject with git status, it is a git repository. The permission rights of the folder are 775.

peace_love
  • 6,229
  • 11
  • 69
  • 157
  • 3
    As a sidenote, it might be confusing to refer to remotes as branches. ("*I tried to use another branch name*" --> This is not a branch, but a remote) – Romain Valeri Sep 05 '22 at 07:22
  • 1
    ssh url is not correct: `user@host:port/path`. Port is 22, you can leave it out: `user@host:/path` – eftshift0 Sep 05 '22 at 07:23
  • @eftshift0 sorry, type mistake. I updated my question – peace_love Sep 05 '22 at 07:24
  • 1
    @RomainValeri's comment is _also_ relevant. Just in case, it's not the source of the problem but they way the OP set it up is not.... consistent. – eftshift0 Sep 05 '22 at 07:25

1 Answers1

1

external Repository origin already exists

Then the command to use would be:

git remote set-url origin ssh://myhost@myuser/html/myproject

But for that, you would need a bare repository in /html/myproject, which it is probably not.

Initializing a bare repository, and adding a post-receive hook is usually the way to updtae /html/myproject content.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Does it have to be bare, I think it is a normal git repository? – peace_love Sep 05 '22 at 08:01
  • I tested the command, I get the error `The authenticity of host '[myhost]:22 ([999.111.222.33]:2222)' can't be established.Failed to add the host to the list of known hosts (coding/.ssh/known_hosts).` – peace_love Sep 05 '22 at 08:03
  • @peace_love I have added links regarding bare repositories. – VonC Sep 05 '22 at 08:07
  • @peace_love Regarding the error message, check out https://stackoverflow.com/q/17668283/6309. – VonC Sep 05 '22 at 08:11