0

如何将git的master分支整个替换为另外一个分支

 9 months ago
source link: https://ooso.net/archives/739
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

如何将git的master分支整个替换为另外一个分支 – 某人的栖息地

Skip to the content

我有一个git仓库,其中master分支的代码已经落后几个月了,而另外一个blah分支却一直在持续提交。现在想把blah分支更名为master,同时也更新remote上的master。

这个操作似乎并不能用简单的git branch -m来解决。搜索发现也有不少人有类似需求,贴上解决方法。

如果blah分支能够快速merge到master分支,那么采用这个方法

git checkout seotweaks
git merge -s ours master
git checkout master
git merge seotweaks

如果分支合并时出现了冲突,而你的remote仓库是github或者bitbucket,那么只能强上了

git branch -m master old-master
git branch -m seotweaks master
git push -f origin master

以上,我的情况只适合第二种,强上成功

Leave a Reply Cancel reply

Your email address will not be published.

Comment

Name

Email

Website


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK