Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
520 views
in Technique[技术] by (71.8m points)

git - 如何解决git所说的“提交更改或在合并之前将其隐藏”?(How do I resolve git saying “Commit your changes or stash them before you can merge”?)

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

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

(我假设w3tc更改了服务器上的配置文件中的某些内容。)

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?

(有任何想法吗?)

  ask by Jo Sprague translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can't merge with local modifications.

(您无法与本地修改合并。)

Git protects you from losing potentially important changes.

(Git保护您避免丢失潜在的重要更改。)

You have three options:

(您有三种选择:)

  • Commit the change using (使用提交更改)

     git commit -m "My message" 
  • 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 
  • Discard the local changes (放弃本地更改)

    using git reset --hard

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

    (或git checkout -t -f remote/branch)

    Or: Discard local changes for a specific file (或:放弃特定文件的本地更改)

    using git checkout filename

    (使用git checkout filename)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...