Note that there are some explanatory texts on larger screens.

plurals
  1. POGit: Pulled the wrong branch, then pushed the merge. How to undo?
    primarykey
    data
    text
    <p>I recently made a mistake with my git merge strategy, and didn't notice the result error(s) until I had already continued to work on the project and made more commits. For the sake of brevity, let's say I have two branches, <code>hotfix</code> and <code>new_feature</code>. I did something like the following:</p> <pre><code>git checkout new_feature git commit -m "Commit to the feature branch" git checkout hotfix git pull origin new_feature # Uh oh, I pulled the wrong branch! git commit -m "Commit to the hotfix" git push origin hotfix # Uh Oh, pushed the bad merge! </code></pre> <p>After the events above, other developers also made commits to the Hotfix branch. Now, we have a hotfix we want to push out, but can't because it contains feature work that isn't complete.</p> <p>I've seen a lot of similar questions about this situation, but none that match 100% (most of them involve undoing the commit directly after the bad pull, without pushing first. I've gone one step further, and really borked things.</p> <p>Any step-by-step guides on how I can remedy this?</p> <p>Thanks!</p> <p><strong>Edit:</strong> many other answers mention <code>git reflog</code>, so here is a modified copy of mine. I've changed the hashes and branch names to match my example above.</p> <pre><code>aaaaaaa HEAD@{0}: checkout: moving from new_feature to hotfix bbbbbbb HEAD@{1}: checkout: moving from hotfix to new_feature aaaaaaa HEAD@{2}: commit: Added analytics tracking ccccccc HEAD@{3}: commit (merge): Fixed a merge issue in compiled css # BAD MERGE? ddddddd HEAD@{4}: checkout: moving from new_feature to hotfix eeeeeee HEAD@{5}: commit: Finished updating the events for the header ddddddd HEAD@{6}: checkout: moving from hotfix to new_feature ddddddd HEAD@{7}: checkout: moving from new_feature to hotfix </code></pre> <p>In the reflog above, <code>HEAD@{3}</code> looks to be the bad merge. I was on the <code>hotfix</code> branch, and pulled in the <code>new_feature</code> branch, which gave merge conflicts. I fixed them, and pushed. What would I do to fix this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload