

Again, the one without a number is also you pile up a lot of stashes, it can get fairly messy (was the stash I wanted or was it Wait, I just pushed another, now they're 8 and 5?). Dropping a specific stash renumbers only the higher-numbered ones.

You can apply and then drop a specific stash, too: git stash apply and so on. If you had, even more, the one that was becomes and so on. When you git stash drop, it drops the newest, and the one that was moves to the top of the stack. The newest is always the lowest-numbered. If you do that, you have two stashes, one just called stash-but you can also write one spelled Use git stash list (at any time) to see them all. You can in fact git stash save again, as git stash makes a "stack" of changes. Now you want to keep, or even move, these changes, and apply your stash too. Then you switched to another branch and started more changes, forgetting that you had the stashed ones. You started some changes and stashed them.Inspect the results carefully (with git diff) to see if you like them, and if you do, use git stash drop to drop the stash. This gets Git to merge in your earlier changes, using Git's rather powerful merge mechanism. Check out the other branch and use git stash apply.

Run git stash save (or plain git stash, same thing). You just want to take the changes you have now and "move" them to another branch. You started with a clean branch, were working on some changes, and then realized you were doing them in the wrong branch.The above is for "way 1", the "easy way": There are at least three or four different "ways to use git stash", as it were. What if you're doing more-advanced or more-complicated stuff? It's all pretty minor one way or the other though, and for a newbie to Git, it should be about the same. If you apply, you get to choose when to drop. If pop is able to extract the stash, it will immediately also drop it, and if you subsequently realize that you wanted to extract it somewhere else (in a different branch), or with -index, or some such, that's not so easy. The difference is that apply leaves the stash around for easy re-try of the apply, or for looking at, etc. I always suggest using git stash apply rather than git stash pop. Then use git diff to see the result.Īfter you're all done with your changes-the apply looks good and you're sure you don't need the stash any more- then use git stash drop to get rid of it. Just check out the branch you want your changes on, and then git stash apply. The easy answer to the easy question is git stash apply I want to know is there a way to rool back the state before execute the sudo git stash apply, just after or before execute git add.
#Abort git stash pop how to
I come in the question How to reverse apply a stash? asked by Pat Notz, and tried the solution of that question. $this->waitUntilAllCommandsAreParsed = true // Don't destroy string until executed $this->text = 0 // Terminate string overwriting checksum and sudo git stash apply commands by fault, and it shows this info, sudo git stash applyĪuto-merging app/controllers/CloudGcode.phpĬONFLICT (add/add): Merge conflict in app/controllers/CloudGcode.phpĪuto-merging app/controllers/CloudController.phpĬONFLICT (content): Merge conflict in app/controllers/CloudController.phpĪfter the stash apply, there is conflict in my file like this, text = $text The changes in my working repository have conflict with the Then I execute the git add. I have a stashes in my stash list, and I have do some modify in my working repository. I have to explain how I run in this situation.
#Abort git stash pop Patch
And I have tried the approved answer, but I get such an error, sudo git stash show -p | git apply -reverseĮrror: patch failed: app/controllers/CloudController.php:673Įrror: app/controllers/CloudController.php: patch does not applyĮrror: patch failed: app/controllers/CloudGcode.php:1Įrror: app/controllers/CloudGcode.php: patch does not apply I have seen the question How to reverse apply a stash? asked by Pat Notz.
