簡體   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