Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

git - Make my github master branch match another branch

I've been working on a forked branch "forkedBranch" and made many updates to my app. When I was happy with the updates, I went back to my master branch (git checkout master) and merged my forkedBranch (git merge forkedBranch). Unfortunately, the master branch has lots of problems with it that weren't present in forkedBranch.

The app is too complicated for me to want to go through and find all the bugs. Is there a way to make my master branch identical to forkedBranch to save me the hassle?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)

If you're absolutely certain you don't need the master branch or any of its old commits:

  1. git branch --delete master && git push origin -delete master - delete the master branch locally and on origin
  2. git checkout forkedBranch && git pull origin forkedBranch - pull down the latest forkedBranch from origin
  3. git checkout -b master && git push origin master - recreate the master branch locally from the latest commit of forkedBranch, and push it up to origin

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
...