简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM