I am relatively new to git so this issue might be my own fault. But it’s too fragile in my humble opinion. Any advice to revert the damage would be appreciated.
Here is my branch setup.
Machine A (Mac):
master
couch
Machine B (Windows):
master
On Machine B, I am trying to pull both master and couch branches from Machine A. Unfortunately, I forgot I haven’t created the couch branch on Machine B yet. Here is what I did on Machine B. origin is set to Machine A.
git pull origin master
git pull origin couch
To my surprise, git automatically merge couch branch into master on machine B! My expectation is for git to create couch branch on machine B for me if it doesn’t exist.
How do I undo the merge? I am not ready to merge couch branch into master yet. I am going to delete it altogether on Machine B and clone again from Machine A. I am just curious if there are better solutions.
git pull origin couchwill fetch the couch branch from Machine A and merge it with the current branch, which in your case would have been master and that is why you see couch merged into master. All you had to do was a simple
git pulland then agit checkout -b couch origin/couchJust do
git reflog, see where your master was previously and dogit reset --hard <sha from reflog>or something likegit reset --hard HEAD@{2}Or you can do
git reset --hard ORIG_HEAD