为什么无法将隐藏应用到工作目录? [英] Why can't stash be applied to the working directory?

查看:76
本文介绍了为什么无法将隐藏应用到工作目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将存储应用回工作目录.

I cannot apply stash back to the working directory.

小故事:

首先,我尝试推送一些已提交的更改,但它说:不,您不能,先拉".然后,我将从GitHub中拉取内容,然后推送我的更改.当我尝试拉动它时,它说我有将被覆盖的更改,并且我应该存储我的更改.好的,我隐藏了更改...拉了,然后推送了已提交的更改.但是现在,我无法恢复我正在处理的未提交的更改.

First I tried to push some committed changes, but it said: "no you can't, pull first"... OK then, I'll pull things from GitHub and then push my changes. When I tried to pull, it said that I had changes that would be overwritten, and that I should stash my changes. OK, I stashed the changes... did the pull, and push the committed changes. But now, I cannot restore the uncommitted changes I was working on.

这是错误:

MyPath/File.cs already exists, no checkout
Could not restore untracked files from stash

肯定我还不了解git的所有概念,它们使我有些困惑……也许我做错了事.

For sure I don't yet understand all the concepts of git, they confuse me a bit... maybe I did something wrong.

如果有人可以帮助我解决这个问题,那就太好了……我已经搜索了google和所有内容超过一个小时,而我还没有找到解决方法.

It would be great if someone could help me solve this... I've been searching google and everything for more than an hour now, and I didn't come to a solution yet.

非常感谢您的帮助.谢谢!

Help is much appreciated. Thanks!

推荐答案

听起来您的存储中包含未跟踪的文件,该文件随后被添加到了仓库中.当您尝试将其检出时,git会正确拒绝,因为它将覆盖现有文件.

It sounds like your stash included an untracked file that was subsequently added to the repo. When you try and check it out, git rightly refuses because it would be overwriting an existing file.

要解决此问题,您可以执行以下操作,例如删除该文件(没关系,它仍在存储库中),应用存储,然后根据需要用存储库中的版本替换文件的存储版本.

To fix, you could do something like deleting that file (it's okay, it's still in the repo), applying your stash, and then replacing the stashed version of the file with the in-repo version as appropriate.

编辑:也有可能仅在工作树中创建了文件,而没有将添加到存储库中.在这种情况下,不要简单地删除本地文件,而是:

It's also possible that the file has only been created in the working tree without having been added to the repo. In this case, don't simply delete the local file, rather:

  1. 将其移动到其他地方
  2. 应用隐藏
  3. 手动合并两个文件版本(工作树与移动文件).

这篇关于为什么无法将隐藏应用到工作目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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