我已经使用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?

最佳答案

要将变更集推送到gogs,您需要在gogs上创建一个仓库,然后添加一个使用容器启动时暴露的端口的远程服务器。如果不确定,请运行以下命令并记下HostPort条目。假设该容器名为gogs:

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

以下是设置ssh远程来源的步骤。
使用可以通过3000 / tcp的HostPort条目访问的gogs Web ui添加公共(public)密钥。如果您遵循gogs docker 说明,则可能是:http://localhost:10080如果gogs不在本地运行,请用gogs主机名替换localhost。

将以下主机项添加到~/.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.

将以下内容添加为您的 Remote :
git remote add origin gogs:yourusername/your-repo.git

请注意,您正在用git@localhost ssh主机条目替换gogs

现在,您应该可以推送到Gogs存储库了。

07-24 12:33