Daniele Dolci
Daniele Dolci

Reputation: 884

Retrieve the path of a git repository

I created on my server a git repository with commands:

$ cd /var/www/html
$ git init
$ git add .
$ git commit -m 'inital commit'

Now, i need to clone this repository on my local machine. How can i retrieve the correct path for git clone?

Thanks

Upvotes: 0

Views: 97

Answers (2)

Monzurul Shimul
Monzurul Shimul

Reputation: 8386

You need to set up an empty repository by running git init with the --bare option, which initializes the repository without a working directory:

$ cd /srv/git
$ mkdir project.git
$ cd project.git
$ git init --bare
Initialized empty Git repository in /srv/git/project.git/

Then on your computer,

$ cd myproject
$ git init
$ git add .
$ git commit -m 'initial commit'
$ git remote add origin git@gitserver:/srv/git/project.git
$ git push origin master

At this point, you can clone it down and push changes back up just as easily:

$ git clone git@gitserver:/srv/git/project.git
$ cd project
$ vim README
$ git commit -am 'fix for the README file'
$ git push origin master

Reference: https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server

Upvotes: 2

esemve
esemve

Reputation: 360

If you don't use any git server you can clone it from ssh:

git clone ssh://YOURSSHUSER@YOURSERVERIP:sshport/var/www/html/.git

For example:

git clone ssh://[email protected]:22/var/www/html/.git

Upvotes: 2

Related Questions