的路上,我在我的服务器上创建了命令一个Git仓库:检索一个Git仓库
$ cd /var/www/html
$ git init
$ git add .
$ git commit -m 'inital commit'
现在,我需要克隆我的本地机器上这个仓库。我如何检索git clone的正确路径?
感谢
的路上,我在我的服务器上创建了命令一个Git仓库:检索一个Git仓库
$ cd /var/www/html
$ git init
$ git add .
$ git commit -m 'inital commit'
现在,我需要克隆我的本地机器上这个仓库。我如何检索git clone的正确路径?
感谢
如果你不使用任何git的服务器,你可以从SSH克隆它:
git clone ssh://[email protected]:sshport/var/www/html/.git
例如:
git clone ssh://[email protected]: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 [email protected]:/srv/git/project.git
$ git push origin master
在这一点上,你可以复制下来,并备份一样容易推的变化:
$ git clone [email protected]:/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
注意,SSH还需要一些配置,这取决于操作系统OP所使用的 – Dunno
以上将无法正常工作,所以需要将git init与--bare在服务器上。 – mhshimul