当我尝试从 git 更新项目时出现此错误:无法保存未提交的更改
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34586093/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
When I try to update project from git I get this error: Couldn't save uncommitted changes
提问by luffy
I'm new on the job. I work as a junior java developer. We use Intellij IDEA java development editor, git(atlassian) and jira. I have a problem with git. This problem is when I try I get an error what is say "Couldn't save uncommitted changes. Tried to save uncommitted changes in stash before Update, but failed with an error.".
我是新来的。我是一名初级 Java 开发人员。我们使用 Intellij IDEA java 开发编辑器,git(atlassian) 和 jira。我有一个 git 问题。这个问题是当我尝试时出现错误,内容是“无法保存未提交的更改。尝试在更新之前将未提交的更改保存在存储中,但因错误而失败。”。
Here is the screen shots of my git configuration and errors.
回答by Milan Kamboya
Go to this repo from git bash.
从 git bash 转到这个 repo。
Then run this command (to check your current unstage changes) :
然后运行此命令(检查您当前的取消阶段更改):
git status
Then apply below command to stash them :
然后应用以下命令来隐藏它们:
git stash save "give proper comment to identify it later"
Now to check your unstage changes are in stash or not run this command :
现在要检查您的 unstage 更改是否在 stash 中或不运行此命令:
git stash list
Now, you can pull your latest changes from your remote branch. (git pull)
现在,您可以从远程分支中提取最新更改。(git pull)
To reapply your stash after pull :
要在 pull 后重新应用您的存储:
git stash apply stash_id
(here, stash_id is like stash@{n})
(这里,stash_id 就像 stash@{n})
回答by Master Bruce
I had the same issue. My solution was to set the global git config!
我遇到过同样的问题。我的解决方案是设置全局 git 配置!
$ git config --global user.name "John Doe"
$ git config --global user.email [email protected]
After that IntelliJ worked fine again.
之后,IntelliJ 再次正常工作。
回答by CodeWizard
Your IDE is trying to stash your changes before he does the merge (pull = fetch+merge) and fail to do it.
您的 IDE 试图在他执行合并(拉取 = 提取 + 合并)之前隐藏您的更改,但未能做到。
It is something like this:
它是这样的:
Tried to save uncommitted changes in stash but failed with an error.
The easiest thing is to open git bash, check the status and then stash, add or discard your changes.
最简单的方法是打开 git bash,检查状态,然后隐藏、添加或丢弃您的更改。
Few notes:
几点注意事项:
Intellij has something internal called shelf, its similar to git stash but the files are stored and handled by IntelliJ and not by git, so keet this in mind if you decide to stash
(shelf
) within the IDE.
Intellij 内部有一个叫做shelf 的东西,它类似于git stash,但文件是由IntelliJ 而不是由git 存储和处理的,所以如果你决定在IDE 中stash
( shelf
)记住这一点。
回答by Nantoka
Just experienced the same issue with Android Studio. Using <Git Directory>\cmd
instead of <Git Directory>\mingw64\bin
as path to the Git executable solved the problem for me.
刚刚在 Android Studio 上遇到了同样的问题。使用<Git Directory>\cmd
而不是<Git Directory>\mingw64\bin
作为 Git 可执行文件的路径为我解决了这个问题。
回答by MILAN POKHARNA
I have fixed this issue. First open your project in explorer , then right click and open Git bash for here. then apply command git stash pop. this will clear the stash entries and you will be able to update your project now.
我已经解决了这个问题。首先在资源管理器中打开您的项目,然后右键单击并在此处打开 Git bash。然后应用命令 git stash pop。这将清除存储条目,您现在可以更新您的项目。