2013-02-25 44 views
1

在我的Git repo中,有一個配置文件,我想保持不同於主共享回購(它必須保持跟蹤),所以更改不會填充到其他開發人員。然而,'--assume-unchanged'很適合在本地保存我的更改,同時將代碼推送到其他存儲庫。這個問題就變得,當我需要獲得最新的代碼,我拉或共享回購融入我的地方,然後我得到的錯誤:被跟蹤的忽略和 - 默認 - 如何合併

error: Your local changes to the following files would be overwritten by merge: 
    app/grails-app/conf/BuildConfig.groovy 
Please, commit your changes or stash them before you can merge. 
Aborting 

錯誤是有意義的,因爲我有不同的配置文件來自我正在合併的共享回購合同。但是,我怎麼得到拉(合併)最新的代碼,同時保持這種配置不同。我想避免周圍的工作:

git update-index --no-assume-unchanged app/grails-app/conf/BuildConfig.groovy 
git stash save "config file" 

再經過合併讓我改變後的配置:

git stash apply 

如何避免積攢和索引這些額外的步驟 - 假設不變?有辦法拉除一個文件的所有內容嗎?針對所述問題的其他解決方案?

謝謝

回答

4

從我明白了什麼,你要忽略一個文件在本地(意味着其他開發商仍然將跟蹤文件),因此.gitignore不會幫助你,因爲它的影響是全球性的。

但是,如果您將文件添加到.git/info/exclude,它將被本地忽略。

這句話是從.gitignore

Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user's workflow) should go into the $GIT_DIR/info/exclude file

+0

謝謝ogzd。我也可以做全局忽略:git config --global core.excludesfile pathTo/.gitignore_global。但是,如果文件是由git跟蹤的,則忽略不適用,這是必要的。更多在http://margotskapacs.com/2013/02/locally-untracked-files-in-git-while-making-a-grails-plugin-in-place/ – latvian 2013-02-26 19:06:09

+0

推送代碼沒有問題(配置文件索引 - -assume-unchanged),但是需要拉或合併的問題(看起來--assume-unchanged不適用於合併/拉取)。我希望這是有道理的。 – latvian 2013-02-26 19:13:59