2016-04-25 77 views
3

我已經使用Docker安裝了Gogs。後來我創建了一個本地存儲庫這樣的(在現實中,repository有多個分支,等等,但我只是保持這個例子簡單):將本地GIT存儲庫添加到Gogs Docker容器

mkdir repository 
cd repository 
git init 
touch README.md 
git add README.md 
git commmit -m "How do I get this into Gogs" 

我現在該如何遷移/推這對視護目鏡?

回答

2

要將變更集推送到Gog,您需要在Gogs上創建一個回購站,然後添加一個使用容器啓動時公開的端口的遠程設備。如果您不確定,請運行以下命令並記下HostPort條目。假設容器名爲gogs:

docker inspect --format "{{json .HostConfig.PortBindings}}" gogs 

以下是設置ssh遠程原點的步驟。 使用由3000/tcp的HostPort條目訪問的gogs web ui添加您的公鑰。如果您遵循gogs docker說明,這可能是:http://localhost:10080如果gogs未在本地運行,請將localhost替換爲gogs主機名。

以下主機條目添加到~/.ssh/config更容易地指定備用SSH端口:

Host gogs 
    # if gogs is not running locally, add the remote hostname here 
    Hostname localhost 
    User git 
    # the following should match what is listed for HostPort 22/tcp 
    port 10022 

測試與ssh gogs ssh的主機條目。如果一切正常,你應該看到:

PTY allocation request failed on channel 0 
Hi there, You've successfully authenticated, but Gogs does not provide shell access. 
If this is unexpected, please log in with password and setup Gogs under another user. 
Connection to localhost closed. 

添加以下內容作爲遠程:

git remote add origin gogs:yourusername/your-repo.git 

注意你與gogs的ssh主機條目替換[email protected]

你現在應該可以推到你的gogs回購。

+0

謝謝!最初有一些配置問題讓我感到沮喪(https://github.com/gogits/gogs/issues/3019),但現在都很好。再次感謝! – Ole

+0

我很高興它幫助! –

相關問題