简体   繁体   English

将本地GIT存储库添加到Gogs Docker容器

[英]Adding a Local GIT Repository to a Gogs Docker Container

I've installed Gogs using Docker. 我使用Docker安装了Gogs。 Subsequently I have created a local repository like this (In reality the repository has multiple branches, etc. but I'm just keeping this example simple): 随后我创建了一个这样的本地存储库(实际上repository有多个分支等,但我只是简单地保持这个例子):

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

How do I now migrate / push this to Gogs? 我现在如何迁移/推送到Gogs?

To push changesets to gogs, you'll need to create a repo on gogs then add a remote that uses the port exposed when the container was started. 要将更改集推送到gogs,您需要在gogs上创建一个repo,然后添加一个使用启动容器时暴露的端口的Remote。 If you're unsure, run the following and note the HostPort entries. 如果您不确定,请运行以下命令并记下HostPort条目。 Assuming the container is named gogs: 假设容器名为gogs:

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

The following are steps to set up an ssh remote origin. 以下是设置ssh远程源的步骤。 Add your public key using the gogs web ui accessed by the HostPort entry for 3000/tcp. 使用由HostPort条目访问的gogs web ui为3000 / tcp添加公钥。 If you followed the gogs docker instructions, this will likely be: http://localhost:10080 If gogs is not running locally, replace localhost with the gogs hostname. 如果您按照gogs docker说明操作,则可能是: http:// localhost:10080如果gogs未在本地运行,请将localhost替换为gogs主机名。

Add the following host entry to ~/.ssh/config to more easily specify an alternate ssh port: 将以下主机条目添加到~/.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

Test the ssh host entry with ssh gogs . 使用ssh gogs测试ssh主机条目。 If it works you should see: 如果它有效,你应该看到:

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.

Add the following as your remote: 将以下内容添加为远程:

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

Note that you're replacing git@localhost with the gogs ssh host entry. 请注意,您正在使用gogs ssh主机条目替换git@localhost

You should now be able to push to your gogs repo. 你现在应该可以推送你的gogs回购。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM