Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Overwrite master with branch

Tags:

git

I want to overrite master with a particular branch after making changes to it, what I done to do it is:

Step 1: Checkout brranch from Git, using command :

git checkout branch_name 

Step 2: I done some changes in code, now I want to make this branch as master, for that I first run the command:

git status 

Above command list me all the modified files.

Now my question, what all I need to do overrite master with this particular branch "my_branch"?

like image 759
Arpit Aggarwal Avatar asked May 07 '15 15:05

Arpit Aggarwal


People also ask

How do I overwrite git master?

Using the -f flag, your previous master is completely overwritten with develop , including its history.

How can I change master branch to another branch?

First, make sure that the target branch exists by running the “git branch” command. Now that you made sure that your branch exists, you can switch from the master branch to the “feature” branch by executing the “git checkout” command. That's it!

How do I force git overwrite?

Just like git push --force allows overwriting remote branches, git fetch --force (or git pull --force ) allows overwriting local branches.


1 Answers

git branch -f master dev_branch will rewrite local master branch.

git push remote +dev_branch:master will rewrite remote branch.

  • NOTE: If the above doesn't work, the name remote could be origin for you (i.e. git push origin +dev_branch:master)
like image 69
aragaer Avatar answered Sep 29 '22 10:09

aragaer