When I try to update project from git I get this error: Couldn't save uncommitted changes
Solution 1
Go to this repo from git bash.
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 :
git stash list
Now, you can pull your latest changes from your remote branch. (git pull)
To reapply your stash after pull :
git stash apply stash_id
(here, stash_id is like stash@{n})
Solution 2
I had the same issue. My solution was to set the global git config!
$ git config --global user.name "John Doe"
$ git config --global user.email [email protected]
After that IntelliJ worked fine again.
Solution 3
Your IDE is trying to stash your changes before he does the merge (pull = fetch+merge) and fail to do it.
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.
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.
luffy
Updated on July 13, 2020Comments
-
luffy almost 4 years
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.".
Here is the screen shots of my git configuration and errors.
-
Azat Nugusbayev over 8 years1. Commit your changes to your local branch 2. Pull branch from origin branch 3. Resolve conflicts if exists 4. Push your changes to origin
-
Admin over 8 yearssee stackoverflow.com/questions/24850247/… (your git config is not OK)
-
luffy over 8 yearsI handle it, thank you so much.
-
-
luffy over 8 yearsOk, I did yo what you said but I don't know git commands.Could you say git commands? And thank you
-
luffy over 8 yearsThank you, I run your first command "git status" but I've got "fatal: Not a git repository (or any of the parent directories): .git" error. Why? My local repo is not exists?
-
Milan Kamboya over 8 yearsyou have to go your repo directory like...if your repo is in this directory : C:/workspace/my_project and under this my_project folder you have your application (under this folder you have .git folder )then got to this directory by cd command and then run these command.
-
luffy over 8 yearsYes, I needn't more help for now. Thank you for your interests.
-
CodeWizard over 8 yearsWhat do you need ill help you as much as i can.
-
luffy over 8 yearsNo, this error force me to commit my changes. Firstly I committed my changes on project after that I pull.
-
Milan Kamboya over 8 yearsok. that is the another way....but this might leads to conflict and you have to solve that thing. tha's why i didn't give you that solution. but you have not conflicts then lucky....
-
luffy over 8 yearsThank you very much, If I can't cope with any problem and find any solution I'll ask. Thank you.