Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rsync .git directory

Tags:

git

rsync

This question probably is based on my lack of understanding of the role of .gits and git repositories in general but:

Can I rsync a dir with content that I created with git init between machines ?

I have a repository on my laptop, and the only way to get it away from there is scp/rsync to a remote host, from which I can download it again. Could I rsync the complete directory structure between these hosts?

like image 579
svrist Avatar asked Sep 09 '09 07:09

svrist


People also ask

Can you rsync a git repository?

You can just rsync the . git repository (or even whole repository together with working directory), provided that you don't have any activity in repository during rsync ing (same disclaimer as for using rsync:// protocol).

How do I rsync a directory in Linux?

You also have an empty directory called dir2 . To sync the contents of dir1 to dir2 on the same system, you will run rsync and use the -r flag, which stands for “recursive” and is necessary for directory syncing: rsync -r dir1/ dir2.


1 Answers

There are a few possibilities:

  • You can just rsync the .git repository (or even whole repository together with working directory), provided that you don't have any activity in repository during rsyncing (same disclaimer as for using rsync:// protocol).

  • You can clone or fetch using deprecated rsync protocol (where repository URL / location looks like this: "rsync://host.xz/path/to/repo.git/"). Note that this protocol is deprecated, because if there is any activity in repository, you can get corrupted clone (or fetch).

    Also, as I have heard, it didn't work correctly in the presence of packed refs since 2007, and nobody noticed till recently. It will (it did) disappear in Git 2.8.

  • Or you can create git bundle, rsync it or scp it on other machine, and then clone or fetch from bundle.

like image 168
Jakub Narębski Avatar answered Sep 22 '22 13:09

Jakub Narębski