我正在開發一個專案的分支,我們將其稱為原始 OpenX 和一個更完善、更穩定的分支,我們將其稱為 StableX。由于“政治原因”,它們位于不同的 Git 存盤庫中,我每年從 OpenX 獲取新功能并將它們添加到 StableX,然后對其進行潤色并添加 StableX 功能 - 全部手動。
TL;博士:
在 Git 中是否有類似“合并 repo1 和 repo2;向我展示沖突,所以我手動修復它們并將最后的東西推送到 repo2”之類的東西?
很長的故事:
我還是 Git 的新手(長期 svn 用戶),所以請原諒我混合 SVN 和 git 術語:) 我想知道我是否可以以某種方式自動化我的作業流程:
OpenX 托管在 REPO1 上,StableX 托管在 REPO2 上。
OpenX 有一個“發布”分支,每隔幾個月就會擴展一次,但它仍然有點“未經測驗”(閱讀:從未準備好用于實際生產)。OpenX 的所有者對穩定性修復(僅新功能)不感興趣。更重要的是,原始所有者“不會托管我的'''廢話'''添加、皮膚和他們不需要的東西”。
這就是為什么我有自己的“生產就緒”分支,稱為 StableX。
但是,每年大約有一次,我從 OpenX 獲取所有新功能,將它們包含到 StableX 中,在真實資料上徹底測驗它們,添加一些東西/補丁/修復,并在測驗后將其作為 StableX 發布。
到現在為止,我一直在用 StableX 修復和添加手動修補最新的 OpenX 版本,這需要一天的半手動作業(我的添加/檔案串列 Meld diff)。所以我基本上:
- 從 OpenX SVN1 匯出(切換到 Git 后,“歸檔”)
- 將匯出/存檔復制到臨時目錄中
- 做了差異 添加 修復
- 將路徑化的 OpenX 復制到 StableX 開發分支,將其提交(推送)到 StableX 存盤庫
- 經過測驗,修復了新的錯誤,最終發布了 StableX 的穩定分支
有沒有辦法在兩個回購之間在 git 中自動化這個每年的事情?像“合并 repo1 和 repo2;向我展示沖突,以便我手動修復它們并推送到 repo2”之類的東西?
謝謝 :)
uj5u.com熱心網友回復:
嗯....也許你需要開始進入git 方式,如果稍微偏離一點,這可能會有所緩解。你持有多個回購的事實在 git 中并不重要。Git 關心提交,您可以將它們(例如相同的提交)托管在多個存盤庫中。所以....整個事情可能是這樣開始的:
git clone openx-url my-local
cd my-local
git checkout -b stable origin/main # create stable branch from origin/main
# start doing all your magic in stable branch
# when you are finally happy with how stable branch is after changes are committed:
git remote add stable-repo my-stable-repo-url
git push stable-repo stable # hold stable branch in stable repo
# a year goes by
# let's make sure we are on our stable branch
git checkout stable
# let's see what is in openx and merge those changes
git fetch origin
git merge origin/main
# now you start having fun to stabilize the whole thing and correct al issues
# when you are finally happy with what you got
git push stable-repo stable
# let's wait for one more year
現在....讓我們假設您在兩個單獨的本地存盤庫中擁有兩個獨立的歷史記錄...是否仍然可以更正它并將其全部存盤在一個存盤庫/單個歷史記錄中,以便您可以繼續使用每年的 git 合并作業流程?當然,有可能......讓我們假設你不太關心你為穩定分支所做的歷史......那么你可以這樣做:
cd local-stable-repo
git remote add unstable url-to-original-openx-repo
git fetch unstable
# now you can see _all_ stuff that is in unstable
# create a branch temporary on the commit from unstable/main that you last stabilized.... it might have been from a year ago, make sure to pick the right one:
git checkout -b temporary id-to-the-commit
# let's put our stable stuff on top of this
git restore --staged --worktree --source=the-local-stable-branch -- . # the stable branch is your local branch
# now, you have all changes use to _stabilize_ them in index, ready to commit
git commit -m "Here is all my magic to stabilize"
# and now you got all the stabilization changes in a single commit
# let's put local main branch over here if we _really_ like it
git branch -f main
# let's push this into our stable repo
git push origin -f main
# now you can merge the changes that were applied on unstable/main after the commit that you last started to work on
git merge unstable/main
# do all your magic to stabilize it
# when you are done
git push origin main
我們現在可以進入年度拉取作業流程:
# wait for a year
git fetch unstable
git merge unstable/main
# stabilize again
git push origin main
# wait for a year....
git fetch unstable
git merge unstable/main
# stabilize again
git push origin main
# wait for a year
# you see the pattern, right?
提示:你有一堆命令......我會坐下來消化它們中的每一個以了解它們在做什么......這將是讓自己進入 git 模式的好方法。隨意提出問題....另外,我可能在這里或那里犯了一個錯誤,因為我是憑記憶寫的,但基礎知識應該是正確的(或者可能是我寫正確的情況)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/531306.html
標籤:混帐
