简体   繁体   中英

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

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://itsme@100.100.100.100:22/var/www/html/.git

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM