• Register
0 votes

Problem :

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

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


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

So I ran the below command,

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

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

Any clues how can I resolve it?

7 5 2
3,870 points

1 Answer

0 votes

Solution :

You can not  merge with your local modifications. Git protects you from losing the potentially important changes.

You have below three options:

· Commit your change using

git commit -m "My message"

· Stash your change using.

Stashing acts as the stack, where you can push the changes, and you pop them in a reverse order.

To stash it, type

git stash

Do a merge, and then pull a stash:

git stash pop

· Discard your local changes

using the git reset --hard
or the git checkout -t -f remote/branch

Or: Discard your local changes for the specific file

using the git checkout filename

9 7 4
38,600 points

Related questions

0 votes
1 answer 216 views
Problem : I have recently started using Git. I am still learning about Git. I tried to do the pull from the remote repository. But now I am facing below error message: "Please enter a commit message to explain why this merge is necessary, especially if it merges an ... nothing is really happening for me. How can I fix the above error message. I am currently learning to use terminal on the OS X.
asked Mar 3 mphil 2.3k points
0 votes
1 answer 123 views
Problem : How can I ignore the below error message on the Git pull? Your local changes to the following files would be overwritten by merge What if I just want to overwrite them? I Have already tried many things like git pull -f, but nothing really works for me.To be very clear, I just want to overwrite the specific changes and not the everything.
asked Jan 2 alecxe 7.5k points
0 votes
2 answers 113 views
Problem : I have the project with two branches as staging and beta. I try to develop on staging, and use my master branch to fix the bugs. git checkout master And do the stuff on it : git add fileToAdd git commit -m "bug fixed ... be overwritten by checkout: src/Pro/ConvocationBundle/Controller/DefaultController.php Please, commit your changes or stash them before you can switch branches. Aborting
asked Dec 18, 2019 alecxe 7.5k points
0 votes
1 answer 35 views
Problem : Currently I am trying to use TortoiseGit on Windows. But when I want to Clone from a context menu of my standard Windows Explorer, I face below error: Please make sure you have the correct access rights and the repository exists How can I make my git work properly?
asked Jan 10 alecxe 7.5k points