+7 votes
1 view
in Devops and Agile by (28.9k 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?

1 Answer

+10 votes
by (49.3k 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.

by (28.9k points)
Thanks, for your detailed information it works for me.
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...