簡體   English   中英

在git中將父主分支重新設置為分支分支

[英]rebase parent master branch in to forked branch in git

我有一個帶有master分支的原始/父git repo,例如https://github.ironman.com/ironman/jarvis.git

現在,我們團隊中的某人已分叉此存儲庫,現在該存儲庫為https://github.ironman.com/steve/jarvis.git ,他在那里對該存儲庫進行了許多更改/提交。

現在我已經分叉了我的朋友史蒂夫的上述倉庫,現在倉庫是https://github.ironman.com/tony/jarvis.git ,在這里我添加了具有大量提交功能的附加功能

同時,父ironman(https://github.ironman.com/ironman/jarvis.git) repo ironman(https://github.ironman.com/ironman/jarvis.git)有很多其他團隊合並的分支,所以現在我的實際需要是將此父倉庫合並到我的回購tony(https://github.ironman.com/tony/jarvis.git)只需一次提交,例如rebase

我已經從我的repo(tony)master分支嘗試了一些方法,如下所示

git add remote upstream `https://github.ironman.com/ironman/jarvis.git`
git checkout master
git merge upstream/master

但是通過上述步驟,所有master分支的提交歷史記錄(將近400次提交)都在當前master分支的頂部更新,這是我不希望的,因為我將失去對當前master分支提交歷史的了解,然后嘗試使用rebase

git checkout master
git rebase -i upstream/master

在這里,我的分支和父master分支之間的提交歷史有近200個差異,因此使用上述rebase命令,它詢問/顯示了master分支上每個提交的合並沖突。 因此,我需要分別修復它們以進行近100次提交並運行git rebase-繼續執行100次,這確實是一件繁瑣的工作

所以最后我的問題是如何通過一次提交將父master( ironman repo )分支合並到我的branch( tony master branch )之上?

場景:

                     ironman
                        |
                      steve(forked from ironman)
                        |
                       tony(forked from steve)

我想將Ironman主分支合並到Tony主分支,並在其頂部進行一次提交

如果您不想在冗長的重定基礎中經歷這么多的提交重播,那么顯而易見的替代方法是只做合並:

git checkout master
git merge upstream/master

這將導致單個(合並)提交現在位於您的local master版本的頂部,對應於自兩個master分支分歧以來發生的所有更改。

如果您確實需要走變基路線,那么我認為沒有什么可以避免這些沖突的,因為提交會被一一重播。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM