git stash and git pull

GitEgitGit Stash

Git Problem Overview


I am new to Git and I am using EGit eclipse plugin to commit.

I modified few files and I stashed the changes, then I did git pull in command line which pulled up all the latest commits. Then I did Apply stashed changes from EGit. Now it applied my changes and the changes which pulled from last commit of stashed files went out. I am not sure why it didn't ask me about merge conflicts and overwrote my changes and lost previous commits changes.

How to get those changes?

Git Solutions


Solution 1 - Git

When you have changes on your working copy, from command line do:

git stash 

This will stash your changes and clear your status report

git pull

This will pull changes from upstream branch. Make sure it says fast-forward in the report. If it doesn't, you are probably doing an unintended merge

git stash pop

This will apply stashed changes back to working copy and remove the changes from stash unless you have conflicts. In the case of conflict, they will stay in stash so you can start over if needed.

if you need to see what is in your stash

git stash list

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLollyView Question on Stackoverflow
Solution 1 - GityilmazhuseyinView Answer on Stackoverflow