簡體   English   中英

將git repo中的分支替換為具有更改歷史記錄的另一個分支

[英]Replace branch in git repo from with another branch with changes history

例如,我有一個名為Parser的git repo和一個名為Production的分支。 然后,有一個名為ReParsermaster分支的倉庫

我需要用Reparser / master (兩個文件和提交歷史記錄)替換Parser / Production 我怎樣才能做到這一點?

轉到Parser倉庫。

$ git add remote reparser <reparser/repo/url>  # add a new remote named reparser
$ git fetch reparser                         # sync with 'reparser'

$ git checkout master                        # checkout to master
$ git branch -D Production                   # delete existing local 'production' branch
$ git checkout -b Production                 # create and checkout 'new production'

$ git pull reparser master                   # replace parser/Production with reparser/master
$ git push -f origin HEAD                    # force push to remote Production of Parser 

暫無
暫無

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

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