0

Assume that I have to GIT servers behind a fence, say at git.mycompany.com (with gitea UI) and at git.myclient.com (with github-like UI), both heavily security with VPN, multi factor-authentication etc. I want to deliver my full repository myProduct to git.myclient.com/alice/myProduct since Alice is my point of contact.

Can I do that directly without the detour over a local repository on my computer?

Since I am working remote, and the uplink of mycompany.com is much faster than my own...

My current lengthy and slow approach

In detail, the detour over my computer looks as follows:

  1. Using the (github-like) user-interface, create an empty repository at git.myclient.com called myProduct.
  2. Make sure that my local repository is up to date with git pull.
  3. Check my current remote origin with git config --get remote.origin.url, see e.g. an answer to How can I determine the URL that a local Git repository was originally cloned from?

    In my case, the result simply is https://git.mycompany.com/b--rian/myProduct.git

  4. Change this configuration to the destination repository with git remote set-url origin git@git.myclient.com:alice/myProduct.git.
  5. Generate a key-value pair for ssh using ssh-keygen -o, see https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key
  6. Ask Alice to navigate to Settings > GPG and SSH keys (usually at https://git.myclient.com/settings/keys) and ask her to add my New SSH key from the previous step.
  7. Make sure that the SSH agent is running on my windows box, if not start it with eval $(ssh-agent -s) inside the GIT Bash, see https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
  8. Now, finally, I can push most things to the client using git push --all origin. This is the slow step which I would like to speed up.
  9. The tags have to be pushed separately, I heard: git push origin --tags, see How do you push a tag to a remote repository using Git?
  10. Wind back everything by setting the remote.origin.url to back what it was in step 3, in my case it is a git remote set-url origin https://git.mycompany.com/b--rian/myProduct.git.

Is there an easier way?

B--rian
  • 5,578
  • 10
  • 38
  • 89

2 Answers2

1

Maybe you could use Git mirroring on git.myclient.com.

It's up to clients VCS (Git). Most implementations have mirroring options.

For example, if the client is using Gitlab: https://docs.gitlab.com/ee/user/project/repository/repository_mirroring.html

Drasko Vrucinic
  • 1,074
  • 2
  • 7
  • 5
  • I guess you mean `git push --mirror git@git.myclient.com:alice/myProduct.git` or something? On `mycompany.com` side, I have [gitea](https://gitea.io/en-us/) and I am not sure how to do that there, please see my edits. – B--rian Jun 03 '20 at 14:25
  • Git mirroring has to be set up on your clients GIT software. So their GIT will every now and then (can be configured e.g. 2 mins) pull all the changes to their repo. – Drasko Vrucinic Jun 03 '20 at 14:33
  • Well, I am asking since I read https://github.com/go-gitea/gitea/issues/9766 but I somehow did not manage to do that mirroring on the direct path since between `myclient.com` and `mycompany.com` since I have troubles with the authentication in between. – B--rian Jun 03 '20 at 14:36
  • 1
    Yes, that's prerequisite to make let's say technical user (READ-ONLY) on you GIT which will be used on client GIT for auth and mirroring. – Drasko Vrucinic Jun 03 '20 at 14:42
  • So in case I cannot do that, I may only use my workaround, you are saying? – B--rian Jun 03 '20 at 14:43
  • 1
    Yes, in that case, I would take approach with second remote. But anyway, advice would be also to create a script to that for you. It would be even better if this script could be run on Jenkins or some VPS that you have for services during development in your project. – Drasko Vrucinic Jun 03 '20 at 14:55
1

I think it would be much simpler to add a second remote... and then push into that remote:

git remote add second url-to-new-repo
git push second master develop # push master and develop to second

And so on.

B--rian
  • 5,578
  • 10
  • 38
  • 89
eftshift0
  • 26,375
  • 3
  • 36
  • 60
  • Very valid point I totally overlooked. On the other hand, I guess, I am looking for an option of gitea, I could use for mirroring. – B--rian Jun 03 '20 at 14:32