Can I copy a Git working copy onto another machine?

24,801

Solution 1

You can copy it, everything is inside the .git folder and is not dependant on anything else.

Solution 2

It's also worth mentioning that if you have no local changes ("git status" doesn't show anything you want to keep), you can copy only the .git directory and do a "git checkout ." from the (almost-empty) repository root directory at the end.

If it's a slow link it may also be worth repacking the repository before the transfer.

The only thing I worry a little bit about is if git-svn remembers some user information that you don't want to copy to the other developers.

Solution 3

Nope, it'll be fine to just copy the repo's root directory. Just make sure you get any invisible files, too, especially the .git directory (in the project's root) which contains all the config information for the repo.

Share:
24,801
Xavier Nodet
Author by

Xavier Nodet

Updated on June 06, 2021

Comments

  • Xavier Nodet
    Xavier Nodet almost 3 years

    I am in the process of creating a Git working copy from our SVN server with 'git svn clone'. But this takes quite some time (we have > 20.000 revs and almost 10.000 files). I have some other machines (for other developers) that I would like to setup the same way. Will it be possible to copy the resulting files from the first machine onto others, so as to spend less time?

    In other words, is there anything in a Git working copy that ties it to the machine it was created on?

    Thanks.

  • Chris Johnsen
    Chris Johnsen over 14 years
    Almost true. Aside from configuration items like custom diff drivers and hook scripts that might reference external programs, there are some simple configuration items that usually vary across platforms. When copying between different platforms one should check/set/unset items like core.ignorecase, core.autocrlf, core.safecrlf, core.fileMode (and probably some others). I think it should always be safe to re-clone from a copied .git directory though.
  • Xavier Nodet
    Xavier Nodet over 14 years
    My name and email address indeed appears in .git/logs/refs/remotes/trunk. Although the directory is named 'logs', I wonder if this could be an issue for another developer...
  • Chris
    Chris almost 6 years
    just cloned my whole dev-environment with 4 repos in it by simply copying it a few times and making each its own branch. worked flawlessly.