your local changes to the following files would be overwritten by merge -How do I resolve git saying please commit your changes or stash them before you merge?

DevOps

I made some updates on my local machine, pushed them to a remote repository, and now I'm trying to pull the changes to the server and I get the message;

error: Your local changes to the following files would be overwritten by merge:

wp-content/w3tc-config/master.php

Please, commit your changes or stash them before you can merge.

So I ran,

git checkout -- wp-content/w3tc-config/master.php

and tried again and I get the same message. I'm assuming that w3tc changed something in the config file on the server. I don't care whether the local copy or remote copy goes on the server (I suppose the remote one is best), I just want to be able to merge the rest of my changes (plugin updates).

Any ideas?


If you want to unleash your potential in this competitive field, please visit the DevOps course page for more information, where you can find the DevOps tutorials and DevOps frequently asked interview questions and answers as well.

1
Answers

Replies

You won't be able to merge the local changes. You can handle this situation with one of the following 3 methods.



1. Commits the changes done using the git commit command.



git commit -m "Message"



2. Stash the changes and then pop them out in reverse order.



git stash



Now perform the merge and then pull the stash.



git stash pop



3. Discard the changes made in your local file.



You can use either git reset --hard


or git checkout -t -f remote/branch



If you want to discard a specific file,



git checkout filename

 
 

This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.
WhatsApp
To Top