My master GIT branch seams to have some errors thus I’d like to recheck, re-merge or possibly clone my dev branch over the master branch so the master branch would be a copy of dev.
How can I do that?
Thx.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If the problem is simply that your checked-out files don’t match up with the branch, just use
git resetnormally:That should be all you need. However, if you still want to overwrite master with dev, read on.
If you want to overwrite your master branch with the contents of your dev branch, use
git resetlike so:And then if you want to push this somewhere else:
Note that if your dev branch doesn’t fast-forward from your master branch (which I’m guessing it won’t, since you said that your master branch has some screwed up stuff in it), you’ll need to add the
--forceflag to the push to overwrite it on a remote:Note, however, that this can involve all of the normal caveats of rewriting history a la
git rebase– if anyone else uses this remote, they’ll need to deal with the equivalent of an upstream rebase.To avoid this problem in the future, advise your friend that using
--forceis almost never necessary. If they’re getting conflicts when they try togit push, they shouldgit pullfirst, resolve the conflicts, and thengit push.