tags:

views:

69

answers:

3

I have a server that is hosting my 'bare' GIT repo for a few projects.

I want to know what it takes to move the GIT to another server?

+1  A: 

Doesn't this work?

  • clone it locally
  • create a new empty bare repo in the other server
  • then push the clone.
Scharron
so just setup a new remote?
Blankman
that's probably the easiest (conceptually) way to do it.
Wayne Werner
yes, and then you can delete the old one. You just have to update references (using git remote).That's the power of decentralized VCS.
Scharron
+5  A: 

Just copy the parent directory to the new machine and have the checked out copies update their remote with git remote set-url <remotename> <url>. Once you've verified that the users can push/pull properly with the new remote you can delete the copy from the old machine.

Daenyth
so that command will replace the existing remote? or do I delete the old remote first? I guess it takes into context where you are and updates the remote for the repository in context?
Blankman
Of course, `s/move/copy/` just in case something goes wrong. (or someone tries to pull while it's half-moved)
Jefromi
what is s/move/copy? sorry! I get the idea, don't to a cut and paste which deletes the original...
Blankman
@Blankman: `s/foo/bar` is the syntax for regex replacement in a few languages, and sometimes gets used in casual conversation online to correct text after it's sent.
Daenyth
+1  A: 

Git repositories are location-agnostic as to their host file system, and Git itself does not depend on a persistent server process – so on the server side, all you need to do is just copy the foo.git directory to somewhere on your new server.

And all remotes are equal in Git. So you can just add the new URL as another remote if you want to. Or else you can just open the .git/config file and edit the URL of your existing remote to change it. (If it doesn’t work, you can change it back in the same way.)

Git is very non-magic.

Aristotle Pagaltzis