我試著忽略我的同步中的.git
,.bundle
和node_module
目錄。我嘗試了一堆不同的組合試圖讓它工作,但每次同步時我都可以看到所有這些目錄同步到遠端電腦。
誰能發現我做錯了什麼嗎?
~/.unison/default.prf
# Roots of the synchronization
root = /Users/bob/synced
root = ssh://bob@remotebox/synced
# Paths to synchronize
path = hack/testdir
# Some regexps specifying names and paths to ignore
ignore = Name *.log
ignore = Name .DStore
ignore = Name .DS_Store
ignore = Name *.output
ignore = Name *:*
ignore = Path {*/.git/*}
ignore = Path {*/.bundle/*}
ignore = Path {*/.vagrant/*}
ignore = Path {*/.git}
ignore = Path {*/.bundle}
ignore = Path {*/node_modules}
# Window height
height = 37
# propogate file modification times
times = true
# Log actions to the terminal
log = true
auto = true
batch = true
如果有幫助的話,這是從 OSX 同步到 Windows 10。
答案1
這是一個連結路徑規範和忽略路徑Unison 手冊的部分,因為這是我在回答有關 Unison 的問題時最喜歡的部分。請注意,ignore Name = name
忽略最後一個元件匹配的任何路徑name
。也
[字元]
*
符合任何不包含的字元序列(並且在名稱開頭使用時/
不以 開頭)。.
因此我們可以忽略路徑,就像忽略某些文件類型一樣。考慮到您的.git
,.bundle
和node_module
都會有一個前導/
字符,但可能會在以 a 開頭的隱藏目錄下找到.
,以下幾行是您想要的:
ignore = Name {*/,.*/}.git
ignore = Name {*/,.*/}.bundle
ignore = Name {*/,.*/}node_module
對於只同步整個root
目錄的人來說,有一個不幸的極端情況沒有涵蓋:當這些檔案位於頂層時,就在root
您正在同步的目錄中,在這種情況下,沒有前導/
字元。在上面的設定檔中避免了這個問題,因為只有目錄testdir
與線路同步path = hack/testdir
。無論如何,對於同步整個根目錄的人,您可以添加類似於.*,*
通配模式的內容,但這些模式將匹配任何文件的名稱foo.git
也類似。因此,您可以決定.git
在目錄的頂層不存在任何名為 等的目錄/文件root
,或者如果您foo.git
也可以匹配類似的內容,那麼您可以使用以下行:
ignore = Name {.*,*,*/,.*/}.git
ignore = Name {.*,*,*/,.*/}.bundle
ignore = Name {.*,*,*/,.*/}node_module