Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git diff doesn't work after git stash pop

After git stash pop, there were some conflicts, things like:

<<<<<<< Updated upstream
int foo = 5;
=======
int foo = 6;
>>>>>>> Stashed changes

I resolved them in the code, but now I can't preview my changes before committing them. All I get is this, and I know there are changes:

diff --cc mainwindow.cpp
index 24dc025,2c44ad8..0000000
--- a/mainwindow.cpp
+++ b/mainwindow.cpp

How do I force git diff to compare my current source to the last commit?

like image 755
sashoalm Avatar asked May 10 '13 06:05

sashoalm


People also ask

What do I do after git stash pop?

You can re-apply the changes that you just stashed by using the git stash command. To apply the commit, use the git stash command, followed by the apply option.

Does git stash pop overwrite?

When the pop command runs, it's expected that files from the stash will overwrite the contents of the files in the local working tree, and the updated files will be staged in the git index.

What happens if you git stash twice?

If you made two stashes, then just call git stash pop twice. As opposed to git stash apply , pop applies and removes the latest stash. You can also reference a specific stash, e.g.


1 Answers

Your pop resulted in a merge conflict. In order to resolve it, you need to edit the file (which you already did) and then call git add mainwindow.cpp to tell git, that you have resolved the conflict.

If you want to preview your changes, you can do so with git diff --cached. This is because git add already added your changes to the index.

like image 122
Micha Wiedenmann Avatar answered Oct 17 '22 12:10

Micha Wiedenmann