繁体   English   中英

检索git仓库的路径

[英]Retrieve the path of a git repository

我在服务器上使用以下命令创建了一个git存储库:

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

现在,我需要在本地计算机上克隆此存储库。 如何获取git clone的正确路径?

谢谢

如果您不使用任何git服务器,则可以从ssh克隆它:

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

例如:

git clone ssh://itsme@100.100.100.100:22/var/www/html/.git

您需要通过使用--bare选项运行git init来建立一个空的存储库,这将在没有工作目录的情况下初始化存储库:

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

然后在您的计算机上,

$ 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

在这一点上,您可以将其克隆下来并轻松地将更改推回备份:

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

参考: 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