将本地GIT存储库添加到Gogs Docker容器
我已经使用Docker安装了Gogs。 随后我创build了一个这样的本地存储库(实际上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?
要将更改设置推送到gog,您需要在gogs上创build一个回购站,然后添加一个使用容器启动时暴露的端口的远程设备。 如果您不确定,请运行以下命令并记下HostPort条目。 假设容器被命名为gogs:
docker inspect --format "{{json .HostConfig.PortBindings}}" gogs
以下是设置ssh远程原点的步骤。 使用3000 / tcp的HostPort条目访问的gogs web ui添加公钥。 如果您遵循gogs docker说明,则可能是: http:// localhost:10080如果gogs没有在本地运行,请将localhostreplace为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
testingssh主机条目。 如果有效,你应该看到:
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主机条目replacegit@localhost
。
你现在应该能够推到你的gogs回购。