Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+5 votes
2 views
in DevOps and Agile by (29.3k points)
edited by

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?

closed

1 Answer

+8 votes
by (50.2k points)
selected by
 
Best answer

You can’t modify the local modifications. Because git protects from losing important changes for that we have 3 options:

Option 1: Commit the changes using

git commit -m” custom message”

Option 2: Stash it

Stash can act like a sack. Where you can push changes and pop them in reverse order use the following commands.

git stash

And do a merge and pull the stash

git stash pop

Option 3: Discard the local changes

using 

git reset --hard

or 

git checkout -t -f remote/branch

Or: 

Discard local changes for a specific file

using 

git checkout filename

Also, these git commands will surely help you if you are regularly working with git.

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?
Intellipaat-community
by (29.3k points)
Thanks, for your detailed information it works for me.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...