使用 unison 自动解决冲突

使用 unison 自动解决冲突

我在 OSX 中设置了两个文件夹之间的自定义自动同步齐奏使用以下行:

unison folder1 folder2 -batch -debug update+

一切正常,直到我遇到:

Synchronization complete at 12:01:44  (0 item transferred, 1 skipped, 0 failed)
  skipped: example.txt (contents changed on both sides)

我希望命令能够自动同步最新版本。查看选项:

$ unison -help | grep conflict
 -auto              automatically accept default (nonconflicting) actions
 -copyonconflict    keep copies of conflicting files
 -prefer xxx        choose this replica's version for conflicting changes

.. 这表明解决问题的唯一方法是使用-prefer,但我可能遗漏了一些东西。是否可以通过时间戳指定版本?


编辑:同步报告的所有相关部分:

[update+]   Unchanged file
[update+] buildUpdateChildren(handleChild): example.txt
[update] buildUpdateRec: /path/to/folder1/example.txt
[update] checkContentsChange: archStamp is inode (3373366) / info.inode (3373748) / times: 1433242394.000000 = 1433242527.000000... false / lengths: 110602 - 110611
[update+]   Double-check possibly updated file
[update]   archive digest = (29c46acff8e661513ec7487bc0069c2b,)   current digest = (cdc82c2519076f9e52486b1c881e179d,)

[update+]   Unchanged file
[update+] buildUpdateChildren(handleChild): example.txt
[update] buildUpdateRec: /path/to/folder2/example.txt
[update] checkContentsChange: archStamp is inode (3373726) / info.inode (3373746) / times: 1433242452.000000 = 1433242515.000000... false / lengths: 110602 - 109400
[update+]   Double-check possibly updated file
[update]   archive digest = (29c46acff8e661513ec7487bc0069c2b,)   current digest = (e12ef45f692808d50989ca4b08d8c27f,)

changed  <-?-> changed    example.txt

Synchronization complete at 12:23:37  (0 item transferred, 1 skipped, 0 failed)
  skipped: example.txt (contents changed on both sides)

答案1

我已经放弃了时间戳,并通过添加参数来确定一个版本的优先级

-prefer /path/to/folder1

从而解决冲突。

答案2

我认为这会有所帮助。版本 2.48.4 中的变化如下:

添加了“copyonconflict”首选项,用于复制在发生冲突时将被覆盖或删除的文件。(结合“repeat = watch”和“prefer = newer”首选项,可以在连续同步时以相当安全的方式自动解决冲突。)

相关内容