Ole Ole - 1 year ago 201
Git Question

Adding a Local GIT Repository to a Gogs Docker Container

I've installed Gogs using Docker. Subsequently I have created a local repository like this (In reality the

has multiple branches, etc. but I'm just keeping this example simple):

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?

Answer Source

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. If you're unsure, run the following and note the HostPort entries. Assuming the container is named gogs:

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

The following are steps to set up an ssh remote origin. Add your public key using the gogs web ui accessed by the HostPort entry for 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.

Add the following host entry to ~/ssh/config to more easily specify an alternate ssh port:

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. 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.

You should now be able to push to your gogs repo.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download