Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Change master branch?

Tags:

git

Say I have these git branches:

master
branchone

I want to do this, keeping all history intact:

master -> oldmaster
branchone -> master
like image 273
fancy Avatar asked Sep 06 '11 07:09

fancy


People also ask

How do I switch from master to branch in git?

You can use the git switch - command to undo any changes you make and return to your previous branch. If you instead want to keep your changes and continue from here, you can use git switch -c <new-branch-name> to create a new branch from this point.

How do I change my branch with Master without losing changes?

Merge the changes from origin/master into your local master branch. This brings your master branch in sync with the remote repository, without losing your local changes. If your local branch didn't have any unique commits, Git will instead perform a "fast-forward".


1 Answers

You can use git branch -m.

git branch -m master tmpbranch
git branch -m branchone master
git branch -m tmpbranch branchone
like image 164
CB Bailey Avatar answered Oct 13 '22 10:10

CB Bailey