soccerway
soccerway

Reputation: 12009

How can we undo stash files, later commit and push again

When I tried $git pull, it throws below error, then I continue with $git stash and later on tried $git pull which was good and got my git repo sync with my local directory. Now I would like to undo the stash and commit and push those changes again to github repo ! How can I proceed with that ? Could someone please advise.

$ git pull

error: Your local changes to the following files would be overwritten by merge: package.json Please commit your changes or stash them before you merge. Aborting Updating b5c5440..a45849e

$ git stash

Saved working directory and index state WIP on master: b5c5440 First commit of ABC classes UI tests

$ git pull

Updating b5c5440..a45849e Fast-forward cypress/fixtures/cookies.json | 2 +- cypress/fixtures/tokenData.json | 2 +- get-token.js

Upvotes: 0

Views: 119

Answers (1)

AElMehdi
AElMehdi

Reputation: 592

You can use:

git stash pop

Remove a single stashed state from the stash list and apply it on top of the current working tree state.

Or:

git stash apply <stash>

Like pop, but do not remove the state from the stash list.

Note that you can get the <stash> id using:

git stash list

List the stash entries that you currently have. Each stash entry is listed with its name (e.g. stash@{0} is the latest entry, stash@{1} is the one before, etc.)

Upvotes: 2

Related Questions