0

Is it safe to move a git repository? (assuming that everyone else updates their remotes and symlinks)

In the original question, I had noticed that git creates what seemed to be symlinks under .git/objects. But I now realize that they aren't symlinks.

Note that this question is different from the one asked at: How does git handle symbolic links? since I am asking about symlinks created by git.

As requested in the comments, here is an example:

$ ls -ld ./something.git/objects/7a/f87b48b897fde759daaff2b0a781691d5a625a
-rwxrwxrwx 1 XXX YYY 188 Jan 25 17:12 ./something.git/objects/7a/f87b48b897fde759daaff2b0a781691d5a625a*
Community
  • 1
  • 1
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564
  • I haven't seen this before (symlinks under `.git/objects`) - could you add the output of `ls -ld` for one of these? – Mark Longair Apr 09 '13 at 17:44
  • Thanks @MarkLongair I added an example. – Amelio Vazquez-Reina Apr 09 '13 at 17:47
  • that isn't a symlink - it's a regular file, but with unusual permissions (readable, writable and executable by everyone) - it's probably displayed in an unusual colour by `ls`, which might make it easy to confuse with a symlink. – Mark Longair Apr 09 '13 at 17:49
  • `find -L` says to follow symbolic links when walking through the directory structure - did you mean `find PATH -type l`? – Mark Longair Apr 09 '13 at 17:50
  • Sorry @MarkLongair you are absolutely right. Your point about permissions and colors made me believe that `find -L` was printing symlinks. I am re-formulating the question to specifically ask about whether or not it is safe to move a git repository, although I guess I already know the answer. – Amelio Vazquez-Reina Apr 09 '13 at 17:53

2 Answers2

1

If by 'move', you mean the command mv, then yes, this is safe. Git doesn't make relative path references outside a given repository directory.

Phil Miller
  • 36,389
  • 13
  • 67
  • 90
  • 1
    Should note that git itself won't do it to you, but git won't prevent you commiting relative symlinks to your repo or explicitly adding relative urls as remotes or alternates. – jthill Apr 09 '13 at 18:36
1

in git you can move, rename copy etc without any side effects.

Git store all its information inside the .git folder (inside the root dir) so as long as you dont mess with the .git folder you are safe and can move, copy, rename the folder.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167