Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - move branch to master

I have a branch with actual sources and I did not make any commits for a long time to master, and at the moment it's completely out of date. I want to just replace master's content with the content of my branch. One way to do it is to checkout both branch and master, delete master's content and copy content from branch to master, and after that push result to master.

It works, but I believe there has to be some git command to do it in a simpler way.

Does anybody know how to do it?

like image 561
Rostyslav Druzhchenko Avatar asked Apr 06 '12 13:04

Rostyslav Druzhchenko


People also ask

How do I merge a branch into master in GitHub?

In GitHub Desktop, click Current Branch. Click Choose a branch to merge into BRANCH. Click the branch you want to merge into the current branch, then click Merge BRANCH into BRANCH. Note: If there are merge conflicts, GitHub Desktop will warn you above the Merge BRANCH into BRANCH button.


1 Answers

You can use the following command to have master point to a new location:
git branch -f master branchToMoveMasterTo

What this is actually doing is creating a new branch called master that points to branchToMoveMasterTo. Since we already have a branch called master, we need the -f flag to say we want to delete the original master

like image 199
Andy Avatar answered Oct 20 '22 08:10

Andy