[git] git stash and git pull

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?

This question is related to git egit git-stash

The answer is


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

Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to egit

How to resolve conflicts in EGit Push eclipse project to GitHub with EGit Egit rejected non-fast-forward 'cannot open git-upload-pack' error in Eclipse when cloning or pushing git repository Eclipse EGit Checkout conflict with files: - EGit doesn't want to continue git stash and git pull How do I set up Eclipse/EGit with GitHub? "Auth Failed" error with EGit and GitHub

Examples related to git-stash

What is the intended use-case for git stash? How to recover stashed uncommitted changes How to Git stash pop specific stash in 1.8.3? Difference between git stash pop and git stash apply How to unstash only certain files? Stashing only staged changes in git - is it possible? How do I ignore an error on 'git pull' about my local changes would be overwritten by merge? git stash and git pull Stash just a single file git stash -> merge stashed change with current changes