DEV Community 👩‍💻👨‍💻

Nir Lanka ニル
Nir Lanka ニル

Posted on

git diff> & apply vs stash

I never use git stash and prefer to use git diff HEAD > ../diffs/whatever.diff and later git apply ../diffs/whatever.diff -3 (-3 for 3-way merge enabled).

I know a lot of people use git stash, but I'm not sure it's because they prefer it over git diff, but rather because they haven't considered it.

It could be just me, but I prefer to have my code snippets and changes to be as "tangible" as possible. Ability to back them up, add to git, reuse and all that is much more reliable and convenient with diff > apply.

What are your thoughts?

Top comments (1)

Collapse
 
mistergenest profile image
Evan Genest

I only use stash (been coding 2 years).

I find it helpful to name each stash.

Also helpful to sometimes use APPLY instead of POP from the stash.

Here is a post you might want to check out:

Regex for lazy developers

regex for lazy devs

Sorry for the callout 😆