1. master - stable base code
2. staging - code published on staging currently being tested
3. payments - a feature branch I was developing on.

I was working on some final touches to payments:

$ git add classes/class.payment.invoice.php invoice-prepare.php

$ git commit -m 'Added rand query string to logo to override caching'
[payments 906f797] Added rand query string to dealer logo to override 
caching
 2 files changed, 2 insertions(+), 2 deletions(-)

$ git checkout staging
Switched to branch 'staging'

# git merge payments
Merge made by the 'recursive' strategy.
 classes/class.payment.invoice.php | 2 +-
 invoice-prepare.php               | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

$ git checkout master
Switched to branch 'master'  

$ git merge staging
Updating b8a0e45..834dc62
Fast-forward

23 files changed, 816 insertions(+), 550 deletions(-)

... lots of changes...  Too many ... Oops! I meant to merge payments... 
Wrong branch!

So, I googled frantically and found this:  
https://mijingo.com/blog/reverting-a-git-merge
and based on that, I tried to revert:

$ git revert HEAD
error: commit 834dc629a41cd762eda30a5ffa9df7b57471d770 is a merge but no -m 
option was given.
fatal: revert failed

... Didn't work... So based on error I tried

$ git revert -m 1 834dc629a41cd762eda30a5ffa9df7b57471d770
[master b416de4] Revert "Merge branch 'payments' into staging"
 2 files changed, 2 insertions(+), 2 deletions(-)

... That doesn't sound right - there were 23 file changes ...

Still on master - I try the correct merge now:

$ git merge payments
Already up to date.

Then I compared files with staging and they were identical and I can see 
that the last 2 changes I made to payments were not in master ... It is 
clear that master was not reverted and I reverted the payments commit ... 
Now I am screwed and dont know how to get master back to the state it was 
in prior to the bad merge...

$ git reflog
b416de4 (HEAD -> master) HEAD@{0}: checkout: moving from staging to master
834dc62 (staging/staging, staging) HEAD@{1}: checkout: moving from master 
to staging
b416de4 (HEAD -> master) HEAD@{2}: checkout: moving from payments to master
906f797 (origin/payments, payments) HEAD@{3}: checkout: moving from master 
to payments
b416de4 (HEAD -> master) HEAD@{4}: revert: Revert "Merge branch 'payments' 
into staging"
834dc62 (staging/staging, staging) HEAD@{5}: merge staging: Fast-forward
b8a0e45 HEAD@{6}: checkout: moving from staging to master
834dc62 (staging/staging, staging) HEAD@{7}: merge payments: Merge made by 
the 'recursive' strategy.
eac6d7b HEAD@{8}: checkout: moving from payments to staging
906f797 (origin/payments, payments) HEAD@{9}: commit: Added rand query 
string to dealer logo to override caching
66b3e0b HEAD@{10}: checkout: moving from master to payments

It says "revert" - but I dont think it reverted what I wanted... 
Help? How do I regain my sanity? (and my code)

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/387bf4ed-c8f2-404f-b0fe-2fc1aaa70dd4n%40googlegroups.com.

Reply via email to