I have Git master and dev branches. I inadvertently did something wrong during the process of trying to merge my dev branch into my master branch and it now appears that master is messed up. I know my dev branch is OK and I don't want anything to happen to it so I'm trying to replace my master branch with my dev branch. It would be nice if I could retain my master commit log entries but I'm OK with losing them so long as I can retain everything in dev. I'm trying to implement the solutions described in this Stackoverflow question but they're not working. Here's what I did:
$ git checkout dev
$ git branch -f master dev
$ git checkout master
Switched to branch 'master'
Your branch is behind 'origin/master' by 4 commits and can be fast-forward.
(use "git pull" to update your local branch)
If I then do "git pull", the master branch no longer contains dev's changes and Git tells me my branch is up-to-date with 'origin/master'. What do I do now? How is this overwriting master with dev? Master doesn't contain the dev changes. If I now do "git merge --no-ff dev", Git says "Already up-to-date."
I also tried to implement the second answer by doing the following:
$ git checkout dev
$ git merge -s ours --no-commit master
Already up-to-date.
% git commit
On branch dev
Your branch is up-to-date with 'origin/dev'.
nothing to commit, working tree clean
$ git checkout master
Your branch is behind 'origin/master' by 4 commits and can be fast-forward.
(use "git pull" to update your local branch)
As you can see, this takes me right back to where I was when I tried to implement the first solution. I'm totally confused. How do I overwrite my master branch with my dev branch?