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?
To retrieve changes out of the stash and apply them to the current branch you're on, you have two options: git stash apply STASH-NAME applies the changes and leaves a copy in the stash. git stash pop STASH-NAME applies the changes and removes the files from the stash.
The git commit and git stash commands are similar in that both take a snapshot of modified files in the git working tree and store that snapshot for future reference. The key differences between the two are as follows: A commit is part of the public git history; a stash is stored locally.
git stash is a way to temporarily store some changes to get them out of the way. Now you can do something else, without a lot of fuss. In our case, “do something else” is to get the upstream changes with a nice, simple git pull . Then you reapply and delete the stash and pick up where you left off.
The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content. Merging remote upstream changes into your local repository is a common task in Git-based collaboration work flows.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With