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"?
Using the -f flag, your previous master is completely overwritten with develop , including its history.
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!
Just like git push --force allows overwriting remote branches, git fetch --force (or git pull --force ) allows overwriting local branches.
git branch -f master dev_branch
will rewrite local master branch.
git push remote +dev_branch:master
will rewrite remote branch.
remote
could be origin
for you (i.e. git push origin +dev_branch:master
)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With