I'm using git on a new project that has two parallel -- but currently experimental -- development branches: 我在一個新項目上使用git,該項目有兩個並行的但目前仍處於試驗階段的開發分支: git
master
: import of existing codebase plus a few mods that I'm generally sure of master
:導入現有的代碼庫以及一些我一般肯定的mod exp1
: experimental branch #1 exp1
:實驗分支1 exp2
: experimental branch #2 exp2
:實驗分支2 exp1
and exp2
represent two very different architectural approaches. exp1
和exp2
表明兩種很是不一樣的體系結構方法。 Until I get further along I have no way of knowing which one (if either) will work. 直到我步入正軌,我才知道哪個(若是有的話)會工做。 As I make progress in one branch I sometimes have edits that would be useful in the other branch and would like to merge just those. 當我在一個分支中取得進展時,有時我會進行一些編輯,而這些編輯在另外一分支中將很是有用,而且但願將這些合併。 app
What is the best way to merge selective changes from one development branch to another while leaving behind everything else? 將選擇的更改從一個開發分支合併到另外一個開發分支,同時又保留其餘全部分支的最佳方法是什麼? ide
Approaches I've considered: 我考慮過的方法: spa
git merge --no-commit
followed by manual unstaging of a large number of edits that I don't want to make common between the branches. git merge --no-commit
而後手動取消暫存我不想在分支之間共享的大量編輯。 .net
Manual copying of common files into a temp directory followed by git checkout
to move to the other branch and then more manual copying out of the temp directory into the working tree. 手動將經常使用文件複製到temp目錄中,而後git checkout
移至另外一個分支,而後從temp目錄中進行更多手動複製到工做樹中。 code
A variation on the above. 上面的變化。 Abandon the exp
branches for now and use two additional local repositories for experimentation. 如今放棄exp
分支,並使用另外兩個本地存儲庫進行實驗。 This makes the manual copying of files much more straightforward. 這使得手動複製文件更加簡單。 three
All three of these approaches seem tedious and error-prone. 全部這三種方法彷佛都是乏味且容易出錯。 I'm hoping there is a better approach; 我但願有更好的方法; something akin to a filter path parameter that would make git-merge
more selective. 相似於filter path參數,可使git-merge
更具選擇性。 開發