也許你可以使用一個符號鏈接?如果,例如,文件總是在./etc/app.conf
在倉庫中找到了你可以把它的符號鏈接未追蹤文件:
$ ln -s dev.conf etc/app.conf
$ echo 'dev.conf' >etc/.gitignore
$ git add etc/app.conf etc/.gitignore
$ git commit -m "point `app.conf' to dev config"
$ ls -l etc/
total 3
lrwxrwxrwx 1 user users 8 Sep 30 23:31 app.conf -> dev.conf
-rw-r--r-- 1 user users 13 Sep 30 23:30 dev.conf
符號鏈接是由git的同時dev.conf
被忽略,被跟蹤。當您切換到客戶分支符號鏈接可以切換到一個實際的客戶配置:
$ rm app.conf
$ echo '# customer config' >etc/app.conf
$ git add etc/app.conf
$ git commit -m 'add config for customer A'
$ ls -l etc/
total 3
-rw-r--r-- 1 user users 18 Sep 30 23:35 app.conf
-rw-r--r-- 1 user users 13 Sep 30 23:30 dev.conf
開發人員的自定義配置是保持不變,但app.conf
入口不再指向it.Alternatively,你可以離開app.conf
一個符號鏈接它重新指向跟蹤客戶的配置:
$ echo '# customer config' >etc/customerA.conf
$ ln -sf customerA.conf app.conf
$ git add etc/app.conf
$ git commit -m "point `app.conf' to customer A config"
$ ls -l etc/
total 4
lrwxrwxrwx 1 user users 13 Sep 30 23:31 app.conf -> customerA.conf
-rw-r--r-- 1 user users 18 Sep 30 23:36 customerA.conf
-rw-r--r-- 1 user users 13 Sep 30 23:30 dev.conf
無論哪種方式,etc/app.conf
現在總是混帳無論是在開發分支或客戶分行跟蹤,無論你使用的是追蹤(即客戶)配置或不通過文件系統中的某些間接處理。這應該避免被忽略的跟蹤競爭,一旦它被設置,它基本上是自動的,因爲符號鏈接是存儲庫的一部分。
好主意,謝謝。無論如何,我們可能正朝着安裝腳本的方向前進。 – rimsky