5

I want to copy all my git repos from my old machine to my new machine (both Ubuntu). I will keep using both machines... I am doing this primarily out of laziness (well: there are for some local branches at the moment, and convenient stashes at hand, also the fact that I have multiple remotes connected, ... transfer of all of that is a bit tedious...),

...but (with some pains) yes, I could just well freshly clone from the various upstream repositories...

Question: Is this harmful in some way?

(Of course the repo states should be binary identical, whether I copy files or go for git clone. But I could imagine, git puts some kind of unique (g)uuid into the .git folder upon first clone or so, to distinguish machines or such... but just a guess. I simply don't know the inner workings...)


update: My worries are primarily around uuids or similar, non-uniqueness of then two local git 'repos' ("clients") connecting towards one remote repo ("master/server").

If you know about this being ok or not-ok, I need actual sources for that knowledge (beyond „I believe“ or „It is“).

That being said, I think I found sort of a duplicate of my question on Superuser.

Frank Nocke
  • 590
  • 8
  • 18
  • 1
    There is no such unique identifier. In fact, git was _designed specifically_ to not have the problem you are worried about. You may wish to read the [Git Internals](https://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain) chapter of the [Pro Git](https://git-scm.com/book/en/v2) book. – Michael Hampton Oct 21 '18 at 16:44

2 Answers2

7

There is nothing wrong with repository move from one machine to another.

Git will update its internal configurations (if needed) on first run into the repo.

Maybe you can ask yourself why you need to move a repository like a normal folder, if your codebase needs things that are not included in a clean clone from remote then you're probably doing something wrong.

If you concerns are about project configuration files consider that probably on your new machine you'll have to recreate databases or change path or similar so there's no point in keeping old configurations for your project, start fresh and go clean.

  • As said, there's convenient stashes, multiple remotes connected, etc, etc... it's not about clean-ness of the repo. And things stretch a bit beyond a simple `git clone`. Clarified above. – Frank Nocke Oct 21 '18 at 16:31
3

No harm. I recommend using rsync, but tar or cp will do just as well.

ptman
  • 27,124
  • 2
  • 26
  • 45