Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve git stash conflicts?

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?

like image 905
Janaka Dombawela Avatar asked Jul 04 '18 05:07

Janaka Dombawela


1 Answers

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.

like image 194
Tim Biegeleisen Avatar answered Oct 11 '22 08:10

Tim Biegeleisen