tags:

views:

155

answers:

3

I have a git clone/repo on a development server, but I am now moving to another one. I don't want to commit all my local branches and changes to the main repository, so how can I make an exact copy of everything on oldserver to newserver?

I tried oldserver:~$ scp -rp project newserver:~/project

but then I just get loads and loads of "typechange" errors when trying to do anything on newserver.

Someone said something about x-modes, but how can I preserve that when moving files between servers?

+1  A: 

If you want a git solution, you could try

git clone --mirror <oldurl> <newurl>

though this is only for bare repositories.

If this is a non-bare repo, you could also do the normal clone, followed by something like this:

git fetch origin
git branch -r | grep '^ *origin/[^ ]*$' |
    while read rb; do git branch --no-track ${rb#*/} $rb; done
git remote rm origin

The middle step can of course be done in 5000 different ways, but that's one! (note that the continuation line \ isn't necessary after the pipe in bash - it knows it needs more input)

Finally, I'd suggest using rsync instead of scp (probably with -avz options?) if you want to directly copy. (What exactly are these typechange errors?)

Jefromi
I have no particular preference on how to copy the files, I just chose scp because that's what I usually use. I will take a look at rsync and otherwise come back to your solution.
Jacob R
I'm still curious what the typechange errors are - they're when trying to use git in the new repo? Are they permissions problems? Are the permissions and ownership correct on the new repo?
Jefromi
I ran `git status` and got a bunch of files as modified: "typechange filename". My user and group have the same names, and the files have the same permissions, on newserver as on oldserver.
Jacob R
I did try rsync now and dit not get the typechange errors. However, instead I get `Unable to determine upstream SVN information from working tree history` - I use git-svn...
Jacob R
That error was actually related to me having to change the remote repo URL in the .git/config. I solved it. Your answer suggested rsync, which was what I solved the problem with, thanks.
Jacob R
A: 

I've actually done this, and all I did was tar the repo up first and scp it over. I would think that scp -rp would work as well.

"Typechange" would normally refer to things like a symlink becoming a file or vice-versa. Are the two servers running the same OS?

ebneter
Yes, both are running Debian Lenny. I will try to tar the repo before scping it.
Jacob R
That would explain why rsync fixed it - it's a bit smarter about symlinks.
Jefromi