0

This is very stupid (question or git system or git documentation - I still haven't decided).

I have ssh access to client's server. There is a website domain.com, and there is git repository, they are under /var/www/html. In git config file there are no remotes, but should they be there? Git itself is installed, I can list history for example.

And subject is the question: at local pc how can I push and pull from that repository? Or am I misunderstanding something?

Daemon Painter
  • 3,208
  • 3
  • 29
  • 44
Roman K.
  • 69
  • 6
  • 2
    it looks like you are missing quite a lot of concept of git. I'd suggest you keep reading the docs and maybe follow a couple of tutorials. – Daemon Painter Jan 13 '21 at 13:25
  • 1
    Have you looked at [Git: The SSH Protocol](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols)? Hint: you do not SSH into the server manually. – crashmstr Jan 13 '21 at 13:28
  • Guys, thanks for fast response. The problem is - how to get that repository url, having only domain name and server path to repo (.git folder)? – Roman K. Jan 13 '21 at 13:40

1 Answers1

1

It appears you have a remote repository you'd like to work with from your local machine.

Cloning

You'll need a copy of that repository in your local machine, otherwise how are you going to work with it, right? Let's have a look at the docs:

The SSH Protocol

A common transport protocol for Git when self-hosting is over SSH. This is because SSH access to servers is already set up in most places — and if it isn’t, it’s easy to do. SSH is also an authenticated network protocol and, because it’s ubiquitous, it’s generally easy to set up and use.

To clone a Git repository over SSH, you can specify an ssh:// URL like this:

$ git clone ssh://[user@]server/project.git

Or you can use the shorter scp-like syntax for the SSH protocol:

$ git clone [user@]server:project.git

In both cases above, if you don’t specify the optional username, Git assumes the user you’re currently logged in as. [source]

In your case, the command should be ssh://root@domain.com/var/www/html/.git1, as we were able to hammer out in the comments.

This will clone that repository locally and will set your local clone to point to that repository as remote.

Man, the point is that I have already read that git doc and all related stuff. There is everywhere project.git at the end of command, which is repo name I guess.

Now I see the confusion. Typically, a git repo locally is cloned as a working copy. A working copy has a root dir and, inside, an hidden .git folder. However, this is not always the case, as you may create a repository as bare. It is a convention (not mandatory as far as I know) to init a bare repository as repo.git. A bare repository doesn't possess the hidden .git folder and, as such, ".git" is appended to the root folder name. This is why you often see project.git in the git documentation.

In git config file there are no remotes, but should they be there?

On the remote, probably no, there shouldn't be any. This isn't a general rule (on the contrary) but from your description should be the best answer. On you local clone, on the contrary, there should be one.


1) This tells us two things: if there is a folder .git in that location, then your root folder is html and everything inside of it is under version control. As a consequence, your remote is set up as a working copy. If this is not the case, since you say you are able to run some git commands in the remote, you might want to check if the remote is bare and troubleshoot the root of that repo using these tools.

Daemon Painter
  • 3,208
  • 3
  • 29
  • 44
  • Thanks. Yes, I do understand this: I need url. Question is - what is that repository url and how can I get it? I have a domain name and a path to website project code on a server, that's it. And that is the point of all this discussion... – Roman K. Jan 13 '21 at 13:38
  • So basically, in this case, clone url would be http(s)://domain.com/.git? Correct? But what about ssh? Clone url would also be (consider I have root access) ssh://root@domain.com:/.git? Correct? – Roman K. Jan 13 '21 at 13:50
  • Http is closed. Man, the point is that I have already read that git doc and all related stuff. There is everywhere `project.git` at the end of command, which is repo name I guess. And it confuses. Where to get repo name, huh? And I also haven't found that full path to `.git` folder - not relative to domain name - should be included after `domain.com` in ssh. The ssh solution is `ssh://root@domain.com/var/www/html/.git` :( – Roman K. Jan 13 '21 at 14:30
  • I finally see your point. Please have a look at my edit. You'll have to find out if you are working with a remote that is a bare repository, _or_ a working copy remote. – Daemon Painter Jan 13 '21 at 14:56
  • 1
    Thanks. It is a working copy. I've cloned successfully and I see all git history locally. So basically now question is solved. – Roman K. Jan 13 '21 at 15:13