我爲子項目創建了master的my_branch(請參見下圖)。我不得不從my_branch中刪除很多文件,因爲它們與子項目無關,但這些文件仍然在master中需要。有一段時間,開發發生在master和my_branch中。重建或合併Git分支但保留已刪除的文件
既然子項目已經完成,我想要將my_branch中的更改重新綁定或合併到master。但我想保留所有在my_branch中刪除但仍然存在於master中的文件。最簡單的方法是什麼?
我意識到我應該已經創建了一個單獨的存儲庫並重構項目。但鑑於目前的情況,我能做些什麼,最好不要手動?
不幸的是,我不能假定所有被刪除的文件都在單獨的提交中。
* 172c3f3 (origin/my_branch, my_branch) comment
| * e4f6849 (origin/master, origin/HEAD, master) Merge branch asdf
| |\
| | * c796e73 aafg
| |/
| * 75720e5 Merge branch zxcv
| |\
| | * 7c694e9 changes
| |/
* | 61370ac some
* | 8afc0be development,
* | d14263b bugfixes,
* | 0d5a17f testing,
* | 588cf8f maybe some cleanup
* | 588cf8f here and there
* | e1f990b and a lot of files
* | 146212b removed
* | 09c6278 but they are still needed in master
|/
* 9a53a83 my_branch created here
這裏思考了我的頭頂部開始my_branch,然後提交主。將my_branch合併(或重新綁定)爲master。然後再次追蹤所有文件? – jrahhali