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?
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).
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.
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 rsync
ing (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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With