5

我已经使用 Docker 安装了 Gogs。随后我创建了一个像这样的本地存储库(实际上repository有多个分支等,但我只是保持这个例子简单):

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

我现在如何将其迁移/推送到 Gogs?

4

1 回答 1

4

要将变更集推送到 gogs,您需要在 gogs 上创建一个 repo,然后添加一个远程使用容器启动时公开的端口。如果您不确定,请运行以下命令并记下 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 主机条目ssh gogs。如果它有效,您应该看到:

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

请注意,您将替换git@localhostgogsssh 主机条目。

你现在应该可以推送到你的 gogs 仓库了。

于 2016-04-26T00:30:15.983 回答