![](/img/trans.png)
[英]Apply changes from one branch to another without affecting git history
[英]Replace branch in git repo from with another branch with changes history
例如,我有一個名為Parser的git repo和一個名為Production的分支。 然后,有一個名為ReParser和master分支的倉庫 。
我需要用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.