1

I have been provided the login details (username and password to connect through SSH) to a web server. It contains a web application that I am supposed to submit some regular updates via git. The server is access via its IP address and I can't connect to it via HTTP requests. I ran the git init command inside the root directory (public_html/app) of the web application.

I need to add it as a remote repository but I do not know how: I tried the following:

git remote add APP user@209.32.x.x:public_html/app/app.git

and then

git clone user@209.32.x.x:public_html/app/app.git

But I get

fatal: repository 'APP' does not exist

I am new to git.

first: What do I need to make the app directory a git repo?

second: how to determine what the link of the repo is? (What to clone?)

alexbclay
  • 1,389
  • 14
  • 19
M Reza Saberi
  • 7,134
  • 9
  • 47
  • 76
  • Talk to whoever gave you the login details and find out **if** there is a git repository for this application and **where** this is. A normal web server does not serve git properly, nor does most web applications come with all their source files. – Lasse V. Karlsen Sep 17 '17 at 15:32
  • well they say application and git are now working in the server and I just need to convert it into a repository. – M Reza Saberi Sep 17 '17 at 15:53
  • There's no conversion involved. Either they gave you a valid URL to connect to or not. `git remote add` doesn't do anything except associate a name with a URL; it doesn't attempt to make any sort of initial connection to the URL. – chepner Sep 17 '17 at 19:21

1 Answers1

2

Try to use the absolute path for the folder:

 user@209.32.x.x:/path/to/public_html/app

If you have done a git init within public_html/app, you don't need to add an "app.git".
But you do need to add git config receive.denycurrentbranch updateInstead if you want to be able to push directly to a non-bare repo.

Another approach is to set up a bare repo (which would be more in line with your app.git) folder, and push to it (no receive config needed in that case), with a post-receive hook which will then checkout the latest pushed commit to your site:

git --git-dir=/path/to/project_root/.git --work-tree=/path/to/public_html/app checkout -f

In both case, the question remains: do you have a git repo with the site content history?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250