I master local development with the help of the gita. There is a working computer, a server on which a live version of the site and a repository. The post-update hook is configured in the repository so that when pushing on the local computer, the changes merge onto the working site.

Git, I just started to learn, and therefore not everything is clear. I created several files on the locale for example, renamed something, now I'm trying to merge the changes back, I do:

d:\www\example.ru>git push origin master remote: remote: **** live [Hub's post-update hook] *** remote: remote: From /opt/git/example.ru remote: * branch master -> FETCH_HEAD remote: error: Your local changes to the following files would be overwritten by merge: remote: new test.php remote: Please, commit your changes or stash them before you can merge. remote: Aborting remote: Updating 12b9e07..257f2ae 

And he told me here in response. I understand the translation: "your local changes will be overwritten by the next file". Actually, this file was changed before the push, why the error occurs is not entirely clear. Explain, friends, what do they want from me?

I will add that the file "new test.php" is on the locale, and, it seems, in the repository. It’s not in the site’s folder, as well as some others that are in the locale — i.e. plums in the folder of the working site has never worked, it turns out, the plug is still at the stage of draining into the repository.

  • 2
    the server has a third version of the file with changes that will be lost due to merge, so git refused to perform the operation. moral - do not edit files on the server. - etki
  • And how to ignore and overwrite changes? Or how to solve such situations? And yes, where did the third version come from? One on locale, the second in turnips, in the folder of the site it is not. - hcuser
  • yes there is no third version there. Judging by the log, it’s just that they didn’t commit their local changes in the file, but someone else has already changed the deleted file (maybe it was you, just from another place). Commit your changes or roll back, then do a pull that hangs. - KoVadim
  • > And how to ignore and overwrite changes? git pull -Xtheirs or git pull -X theirs, I don’t remember anymore, in general, a pull with the strategy option theirs> Or how is it customary to solve such situations? There should be no situations with code changes on the server. > One on the locale, the second in turnips, in the folder of the site it is not. As far as I understood, the “site” writes that it has a file that it cannot kill - etki

1 answer 1

reply from comments.


the server has a third version of the file with changes that will be lost due to merge, so git refused to perform the operation. moral - do not edit files on the server.

And how to ignore and overwrite changes?

 $ git pull -s -X theirs 

In general, the strategy option pool of theirs

Or how to solve such situations?

There should be no situations with code changes on the server.

One on locale, the second in turnips, in the folder of the site it is not.

As far as I understood, the “site” writes that it has a file that it cannot sort.