简体   繁体   English

git中的“stash apply”覆盖了从pull中获得的更改

[英]“stash apply” in git override changes got from a pull

I got in this situation today. 我今天遇到了这种情况。 I had some changes in one file to commit but before I wanted to do a pull for this file so I did the next 我在一个文件中进行了一些更改以提交,但在我想要对此文件执行拉动之前,我做了下一个

  1. Stash changes from my working directory 从我的工作目录中隐藏更改
  2. Pulling changes bringing changes in this same file from other person 拉动更改会从其他人那里带来同一文件中的更改
  3. Stash apply my changes Stash应用我的更改

What I have found after "stash apply" is that the changes I got after doing the pull were overriden with with my stash changes. 我在“存储应用”之后发现的是,在执行拉动后我得到的更改被我的存储更改覆盖了。

  1. Is this normal? 这是正常的吗? There shouldnt be merge conflicts when applying my stash changes affect the changes in the same file got from the pull? 应用我的存储更改时,不应该有合并冲突影响从拉取的同一文件中的更改?

  2. How to deal with this situation in order to avoid my stash changes override changes got from a pull? 如何处理这种情况,以避免我的藏匿更改覆盖从拉动获得的变化?

Thanks 谢谢

You can try to stash your local changes first, then pull, then pop the stash. 您可以先尝试存储本地更改,然后拉出,然后弹出存储。

git stash
git pull origin master
git stash pop

You will have to manually resolve anything that overrides changes from remote, because it will have conflicts. 您必须手动解决任何覆盖远程更改的内容,因为它会产生冲突。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM