PositiveGuy
PositiveGuy

Reputation: 20152

Undo git merge origin/master - Bitbucket - Merged wrong branch into local

Here is what I did, and we are using BitBucket.

Originally I created a new branch off our QA branch

I've been working on that branch, making commits to that branch. Now I'm ready to PR the branch but first like any good developer, I wanna see if there are latest changes I can grab that have been checked into the QA branch since I first created my branch off the QA branch to make sure my local changes mesh with whatever is latest in QA at the moment.

So...what I think I did though is I ended up merging what's in the master branch into my branch instead of qa. If I'm right about that (I assume I am..see below, the commands I performed) then I need to back out and do this again but do it right...merge latest from QA and so need to make sure I do that right as well. I am not used to using bit bucket so I don't know if all I had to do was a pull and it would have auto merged QA into mine or what but I usually switch to the branch I want to pull from, then do a merge into my local branch. Well I tried a different way this time rather than that and I think I messed up.

Our branch setup (notice the qa branch is the default branch):

enter image description here

In Bitbucket, created a new branch off our "QA" branch:

enter image description here

From the command line, here is what I did along with my (thought process):

(ok I just pushed my latest changes to my 65 branch. I wonder if with BitBucket, I can just do a git pull and it'll pull latest from the qa branch without having to switch and do a merge from the qa branch into 65?...hmm lets try it)

▶ git pull
remote: Counting objects: 1507, done.
remote: Compressing objects: 100% (906/906), done.
remote: Total 1229 (delta 883), reused 458 (delta 320)
Receiving objects: 100% (1229/1229), 143.31 KiB | 0 bytes/s, done.
Resolving deltas: 100% (883/883), completed with 108 local objects.
From https://xxxx-bitbucket.xxxx.com/xxxx/xxxx/xxxx-framework
 * [new branch]        ****110           -> origin/****110
   32dd6d6b..a255ga3d  ****71            -> origin/****71
 * [new branch]        ****11              -> origin/****11
 * [new branch]        ****37              -> origin/****37
 * [new branch]        ****45              -> origin/****45
 * [new branch]        ****63              -> origin/****63
 * [new branch]        ****71            -> origin/****71
   1wf5v575..55ybb142  dev                   -> origin/dev
 * [new branch]        ****53              -> origin/****53
   q5920b52..j74411sd  master                -> origin/master
 * [new branch]        ****-detail-****-fix -> origin/****-detail-****-fix
   j79rn527..h48c131s  qa                    -> origin/qa
   41957f2k..2j79002f  staging               -> origin/staging
Already up-to-date.

(nope I simply did a pull on my own branch that's already up to date - nobody else is using this branch, duh)

(hmm..lets see what branches we have locally)

▶ git branch
* ****65

▶ git merge origin/master
Auto-merging webpack/helper.js
Auto-merging src/app/xxxx/About.js
CONFLICT (content): Merge conflict in src/app/xxxx/About.js
...bunch of other conflicts
Automatic merge failed; fix conflicts and then commit the result. 

(crap I think I just merged from our master branch into my local branch. I wanted to merge the qa branch into my local branch). I can't tell but I think I need to back this out and revert this. But I'm not sure how, I see suggestions here but trying to determine if I did mess this up and then if I did, hmm which command to use to revert and how I can with BitBucket merge from the qa branch the right way from the command-line)

This is where I stand right now, need help to verify if I messed up and how to revert and merge qa properly into my branch via BitBucket.

Upvotes: 0

Views: 946

Answers (1)

PositiveGuy
PositiveGuy

Reputation: 20152

tried git reset --merge ORIG_HEAD, looks like it worked since I did not commit the changes after I did the merge yet. I just always forget what the hell HEAD means. Obviously it means the head of whatever branch you're currently checked out to...which in my case is the branch I'm working in.

Upvotes: 1

Related Questions