1

I have debug code for couple situations. I store it in stashes. They touches many files. Sometimes in process of coding I need to do debug stash apply.

But after resolving situation there is no way to un-stash temporary "debug2" code back. I should do revert files or in worst case scenario only debug lines of code in classes that I`ve touched previously by hand.

I know that it possible to do first code commit, then debug stash apply and debug commit. And then do third code commit. But it's uncomfortably if I'm not sure that all working changes should go to first code commit.

Is there a way to just un-apply same debug stash code on fly?

Also maybe you know better idea how to work with temporary debug code.

Sergey Senkov
  • 1,490
  • 1
  • 13
  • 23

2 Answers2

1

Here's one example: Un-applying a Stash

git stash show -p | git apply -R
battlmonstr
  • 5,841
  • 1
  • 23
  • 33
  • Works, but does not delete untracked stash files after using `git stash --include-untracked` – Sergey Senkov May 16 '18 at 10:45
  • Edited final variant: `git config --global alias.unapply '!git stash show -p | git apply -R | git clean -df'` After this: `git stash apply` - to add temporary code. `git unapply` - to remove – Sergey Senkov May 16 '18 at 16:12
0

Another approach to un-apply stash is :

git reset --hard

and after checking out to the branch you choose, run this in your Git Bash:

git clean -d -f
Steffi Keran Rani J
  • 3,667
  • 4
  • 34
  • 56