Reputation: 1772
I think this is the stupid thing a developer can do, but I did it accidentally.
I had made changes to local master and did not commit it. And suddenly I made git pull
, and then the local master got updated with my changes and remote repo changes. Now I can merge the changes by resolving conflicts if any. But I want to undo this pull and preserve the changes I have done which are not committed. Is this possible? Correct me if I am wrong. Please help me.
Upvotes: 5
Views: 2065
Reputation: 30317
stash your changes, take back your local branch with a reset --hard and then unstash
git stash save "saving my uncommitted changes so I don't lose them when I reset"
git reset --hard revision-where-branch-was-before-pulling # check git log or git reflog to see the ID you want
git stash pop # get my changes back on my working tree
That should do
Upvotes: 2