Sync directories containing git repository with unison

跟風遠走 提交于 2019-12-03 14:04:58

Based on VonC's advise, I'm going to relax the requirement of live syncing the entire git state and simply ignore the .git directory with unison and just use git fetch.

Relevant part of my .unison/dotfiles.prf:

root = /home/khouli/dotfiles
root = ssh://other_machine//home/khouli/dotfiles
ignore = BelowPath .git

Relevant part of my sync script:

unison dotfiles
(cd $HOME/dotfiles && git fetch)
ssh other_machine 'cd dotfiles && git fetch'

This syncs the files themselves and the commit history. It doesn't sync staging but that's not too important and it might not even be desirable. This also requires that both machines have an appropriate network connection for a git fetch. Otherwise git bundle like VonC suggests could be used.

This is just here incase anyone comes here from google and finds it useful. I'm not marking it as accepted because it'd be interesting if an answer showed up with a way to live sync a git repo.

VonC

A byte-by-byte sync here doesn't work because even with the same files and git state the internal git files may be different.

That is why you don't synchronize a .git folder (other have tried with dropbox, the result was not satisfactory)

I would recommend using git bundle, but the process can be a bit convoluted.

There are other tools for managing and synchronizing dotfiles. One very good one is RichiH/vcsh, presented in GitMinutes #13, and in this blog post.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!