• Register
0 votes
1.9k views

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:

wp-content/w3tc-config/master.php

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

Please log in or register to answer this question.

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 3 views
3 views
Problem: please commit your changes or stash them before you merge.
asked 6 days ago Dan phillip 1.9k points
0 votes
1 answer 252 views
252 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, 2020 mphil 2.3k points
0 votes
1 answer 145 views
145 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, 2020 alecxe 7.5k points
0 votes
2 answers 216 views
216 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 12 views
12 views
Problem : git - Your branch is ahead of 'origin/master' by 1 commit
asked Feb 15 Shovo210 2.2k points
0 votes
1 answer 42 views
42 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, 2020 alecxe 7.5k points
0 votes
1 answer 69 views
69 views
Problem : I am trying to use the TortoiseGit on my Windows. But when I want to Clone it from my context menu of the standard Windows Explorer then I face below error: Please make sure you have the correct access rights and the repository exists In more detail the complete snapshot of ... exit cleanly (exit code 128) (21450 ms @ 17.12.2019 10:36:58) What should I do to make my git work correctly ?
asked Dec 19, 2019 alecxe 7.5k points
0 votes
1 answer 4 views
4 views
Problem : Error: you need to resolve your current index first
asked 1 day ago Shovo210 2.2k points
0 votes
1 answer 7 views
7 views
error: you have not concluded your merge (merge_head exists).
asked Feb 16 ArifulIslam 7.5k points