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

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

问题描述

我在本地计算机上做了一些更新,将它们推送到远程存储库,现在我试图将更改发送到服务器,并收到消息;

 错误:以下文件的本地更改将被合并覆盖:
wp-content / w3tc-config / master.php
请提交您的在合并之前更改或隐藏它们。

所以我跑了 git checkout - wp-content / w3tc-config / master.php 并再次尝试,我得到相同的消息。我假设w3tc在服务器上的配置文件中改变了一些东西。我不在乎本地副本或远程副本是否在服务器上(我认为远程副本最好),我只是想能够合并剩余的更改(插件更新)。



有什么想法?

解决方案

你不能合并本地修改。 Git可以保护您不会丢失潜在的重要更改。

您有三种选择。

1。使用



  git commit -mMy message
提交更改p $ p>

2。存储它。

隐藏行为作为堆栈,您可以在其中推送更改,并以相反的顺序弹出它们。

隐藏类型:

  git存储

执行合并,然后拉出藏匿处:

  git stash pop 



3。使用 git reset --hard 放弃本地更改




git checkout -t -f remote / branch



3。 a)使用 git checkout filename


放弃特定文件的本地更改



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?

解决方案

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

You have three options.

1. Commit the change using

    git commit -m "My message"

2. Stash it.

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

To stash type:

git stash

Do the merge, and then pull the stash:

git stash pop

3. Discard the local changes

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

3. a) Discard local changes for a specific file

using git checkout filename

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

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