I want to sync a directory containing a git repo of my dotfiles on two machines. Both machines will make changes to the files in the repo. Normally I use unison for syncing directories but in this case the files in the .git
directory diverge even when the directory contents are ostensibly the same. Unison throws up its hands and quits when it sees this.
$ unison dotfiles
changed <-?-> changed .git/FETCH_HEAD
changed <-?-> changed .git/ORIG_HEAD
changed <-?-> changed .git/index
changed <-?-> changed .git/logs/HEAD
changed <-?-> changed .git/logs/refs/heads/master
changed <-?-> changed .git/logs/refs/remotes/origin/master
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. How can I sync these directories? After the sync, all non-git files and the git state should be identical on the two machines. By git state I mean commit histories and staging but not necessarily every byte of every internal git file (e.g. .gitignore, .git). I don't know enough about git to go into more detail on what I mean by that but if that's unclear just comment.
I don't want to make any git commits as part of syncing. I see version control and synchronization as two separate issues here.
Putting the words git and sync into google gives results describing how to clone a repo. Just to be clear, none of the uses of "sync" above are referring to git actions.