2016-03-08 109 views
6

我有一個項目有兩個分支foobaar。在這個項目中,我有一個配置文件database1.propertiesdatabase1.properties,其中存儲了數據庫屬性,例如模式名稱和模式密碼。當我在foo分支上工作時,模式名稱是foo,密碼是foo,當我在使用baar分支時,模式名稱是baar,密碼是baar。如何告訴git這些屬性文件只用於我的本地系統,不應該推送到原始回購?我使用egit和tortoiseGit。如何在本地使用git版本文件

+0

也許你應該已經克隆本地項目... –

+0

也許只是不'git的add' – Black

+1

添加它們,並將它們添加到的.gitignore –

回答

3

對於單個分支,您無法阻止所選文件被推送。

當分支被推動時,所有提交將被推送到遠程。

正如你可以讓你在不同分支的變化(具體以當地)(foo-localbar-local等),只要你想在本地系統中的這些變化,使用git merge local-branch --no-commit --no-ff或類似的命令合併到實際分支一種變通方法(這將不要將您的本地特定更改合併到遠程跟蹤分支)。完成後,您可以放棄這些更改(但是,這些更改將始終存在於本地分支中,並且可以隨時應用於實際分支)。

1

路1 - 調整基線不斷

假設有3個分支:

  • master公衆
  • boo私人
  • baar私人

事情是這樣的:

The 2 branches

你開發了master分支的東西,那麼就重訂高手foo和巴爾分支。你需要(1)結帳foo,(2)調整基線foomaster,(3)結帳baar,(4)調整基線baar到高手,那麼它將成爲:

enter image description here

注意:有一再重複這些步驟。

方式2 - 合併

假設相同的3個分支。

結帳foo,併合並masterfoo

enter image description here

請在baar分支samething,最後你將得到:

enter image description here

開發了一些在主後,再次執行這些步驟,並獲得:

enter image description here

方式3 - 子模塊

以上2種方式是有點危險的,如果你把所有的分支遠端。這種方式更復雜,你需要知道如何使用子模塊,但我更喜歡它。 :)

(1)準備專用數據庫的數據倉庫,您可以檢出foo/baar之間的分支。

enter image description here

enter image description here

(2)準備另一個正常/簡單回購容器,是這樣的:

enter image description here

enter image description here

(3)然後加那個數據回購作爲一個子模塊進入這個回購:

enter image description here

你將得到這些承諾後:

enter image description here

enter image description here

(4)同樣,添加公共回購,這裏命名test,作爲一個子模塊:

enter image description here

enter image description here

現在,你可以在test回購開發和數據回購的另一邊檢出的分支。

注1:需要調整好路徑。

注意2:如果你不喜歡子模塊,你可以使用一個文件夾作爲容器,然後把這兩個回購。

路4 - 合併沒有提交或壁球

由於this answer(由@Royal平託)說,我在這裏展示的TortoiseGit操作。

enter image description here

enter image description here

注:私有數據已經​​上演到索引文件。以便下一個提交命令將它提交回購。

相關問題