0

Hello I was reading this:

https://confluence.atlassian.com/display/STASH/Importing+code+from+an+existing+project#Importingcodefromanexistingproject-ImportanexistingGitprojectintoStash

The part where it says mirror existing git repository.

This is the situation, I'm trying to mirror the repository on a server, into a local directory on my computer, that is on an internal network.

If I do this to the repository on the server:

git remote add stash http://username@192.168.1.101:7999/yourproject/repo.git

i dont think it would work because the live server knows nothing about the private ip on the local network.

how would i be able to do this?

SQB
  • 3,926
  • 2
  • 28
  • 49
Masu
  • 1,568
  • 4
  • 20
  • 41

2 Answers2

1

In order to make a mirror of an external git repository on an internal private server, you have several possibilities:

  1. make the private server be accessible from the internet (with port forwarding on your firewall/router, SSH tunnelling or something like this). Then you can setup/instruct the external server to periodically push its content to the [formerly] private server. This could lead to a serious security breach though, so I wouldn't recommend it.
  2. if the private server has access to internet, you may setup/instruct the repository on the private server to periodically pull changes from the external server (and push its "local" changes back).
  3. if the private server doesn't have access to internet, you may use an intermediate host in your private network, on which you first pull the changes from the external server repository and then push them to the internal server repository and vise versa, effectively using this intermediate host as a mirror for both "internal" and "external" repositories.

If the private server repository resides on your workstation, then simply pull changes periodically from the external server (and push new local changes back). If you need to "proxy" the external server to colleagues in the private network (e.g. to speed up work if internet connectivity isn't that fast or stable) then configure access to the private server repository, e.g. with SSH server being run on your workstation. Take a look at the documentation for the [gory] details.

user3159253
  • 16,836
  • 3
  • 30
  • 56
  • the local repo, would be in this case the server repo correct? the cloned repo != local repo, right? – Masu Oct 23 '14 at 20:22
  • how would i be able to do it with scp? how can i have the terminal know that the ip is on an internal network? – Masu Oct 23 '14 at 20:24
  • if i ssh into the live server using terminal, and execute git remote add stash server on that live server, how can i tell the terminal to use the internal network ip address, since the local network has no public domain i can use? – Masu Oct 23 '14 at 20:25
  • thank you for your detailed response. it looks like my option is option #2, however if i were to do this, i would do a git clone first, then periodically a git pull, and then a git push to the local stash ? however i tried this, and received some type of error. the git push to the stash server is about 18 mebibytes. and when i tried to do that i ran into the problem: remote end hung up unexpectedly rpc failed result=22 http code = 500, so i found this: https://confluence.atlassian.com/display/STASHKB/Git+Push+Fails+-+fatal%3A+The+remote+end+hung+up+unexpectedly so i tried that but a no go – Masu Oct 23 '14 at 22:18
  • another site said to do a git fsck on the client computer, but that also did not work. – Masu Oct 24 '14 at 00:28
  • As far as I remember, git can't push over HTTP, git HTTP transport is intended to be "read-only view" of the repo. In order to have both directions transfers you need to use git over SSH, as described in the provided docs. – user3159253 Oct 24 '14 at 01:11
  • Update: just discovered http://git-scm.com/blog/2010/03/04/smart-http.html Actually pushes over HTTP are possible, although pushes over SSH are still in wider use. The world is changed, I smell it in the air... – user3159253 Oct 24 '14 at 01:14
  • hmm oh ok. well i followed the directions that stash gave me, it told me to use: git remote add stash http://username@localhost:7990/scm/masu/masu.git – Masu Oct 24 '14 at 01:18
  • so i used that url to add that stash remote for the local repo: https://confluence.atlassian.com/display/STASH/Importing+code+from+an+existing+project#Importingcodefromanexistingproject-ImportanexistingGitprojectintoStash – Masu Oct 24 '14 at 01:20
  • ok, this is weird, bought git stash for 10 bucks and set it up on my windows machine. i did git clone ssh://username@host.com/path/to/git/repo/.git, then did git remote -v, git remote rm origin, then did git git remote add stash http://username@localhost/path/to/git.git, then did git push --all stash and it worked. why it did not work on my other mac machine is beyond me – Masu Oct 24 '14 at 02:07
0

when I tried to push using the ip address on the host machine, it would fail, but if i used http://username@localhost:port/path/to/.git it worked. so I guess on a host machine you have to use localhost? you can't use the actual ip address.

Masu
  • 1,568
  • 4
  • 20
  • 41