简体   繁体   English

检索git仓库的路径

[英]Retrieve the path of a git repository

I created on my server a git repository with commands: 我在服务器上使用以下命令创建了一个git存储库:

$ 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? 如何获取git clone的正确路径?

Thanks 谢谢

If you don't use any git server you can clone it from ssh: 如果您不使用任何git服务器,则可以从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: 您需要通过使用--bare选项运行git init来建立一个空的存储库,这将在没有工作目录的情况下初始化存储库:

$ 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 参考: https : //git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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