5

I have a repository where a stash is applied. However now the code looks likes this:

<<<<<<< HEAD
        wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
        exit();
    } else {
        wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
=======
        wp_safe_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
        exit();
    } else {
        wp_safe_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
>>>>>>> dev-wip

The problem is now the stash is not showing in the git. And it does not show any conflicts. How to resolve this?

CKE
  • 1,533
  • 19
  • 18
  • 29
Janaka Dombawela
  • 1,337
  • 4
  • 26
  • 49

1 Answers1

6

What you are seeing is how Git represents a merge conflict in a source code file. The markers <<<<<<<, =======, and >>>>>>> are merge conflict markers, and they separate the two versions coming from each parent in the merge. I am guessing that the version dev-wip is coming from your Stash. If you want to use that version, then just edit your file so the snippet above looks like this:

wp_safe_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
    exit();
} else {
    wp_safe_redirect( 'https://' . $_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI'] );

Then, save the file and finish applying the stash. You may want a version which is a combination of the two shown to you. In that case, make the appropriate edit.

Note that you should generally lean towards doing git stash apply rather than git stash pop, because the latter removes the stash from the stack, and it won't be available again later should something go wrong.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • 1
    But the problem is that I have more than 500 files like this. :( :( – Janaka Dombawela Jul 04 '18 at 05:56
  • 1
    @JanakaDombawela Then you might be doing something wrong, or perhaps you need to change your approach. With 500 files in conflict, it looks like your stash is massively out of date with the current branch. – Tim Biegeleisen Jul 04 '18 at 05:57
  • 2
    @JanakaDombawela Might be the moment to consider going back in history, either with a reset to a specified commit or with a reflog before the stash pop. – Romain Valeri Jul 04 '18 at 06:16
  • 2
    If there is a need to recover the stash, then https://stackoverflow.com/q/89332/2311167 could help. – Adrian W Jul 04 '18 at 08:16