我如何解决 git 说“在合并之前提交您的更改或隐藏它们"? [英] How do I resolve git saying "Commit your changes or stash them before you can merge"?

查看:32
本文介绍了我如何解决 git 说“在合并之前提交您的更改或隐藏它们"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地机器上进行了一些更新,将它们推送到远程存储库,现在我正在尝试将更改拉到服务器并收到消息;

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.

所以我跑了,

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

再试一次,我得到了同样的消息.我假设 w3tc 更改了服务器上配置文件中的某些内容.我不在乎服务器上是本地副本还是远程副本(我认为远程副本最好),我只想能够合并我的其余更改(插件更新).

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).

有什么想法吗?

推荐答案

不能与本地修改合并.Git 保护您免于丢失潜在的重要更改.

You can't merge with local modifications. Git protects you from losing potentially important changes.

您有三个选择:

  • 使用

    提交更改
git commit -m "My message"

  • 把它藏起来.

    存储就像一个堆栈,您可以在其中推送更改,并以相反的顺序弹出它们.

  • Stash it.

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

    要隐藏,输入

    git stash
    

    进行合并,然后拉出存储:

    Do the merge, and then pull the stash:

    git stash pop
    

  • 放弃本地更改

    使用git reset --hard
    git checkout -t -f remote/branch

    使用 git checkout 文件名

    这篇关于我如何解决 git 说“在合并之前提交您的更改或隐藏它们"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆