News for hackers. Stuff that matters.
Re:This is how I git by ricardobeat on Tuesday November 10, 2020 @06:47AM (#25044902)

    git add .
    git commit -m "wip"
when you're back

    git reset HEAD^
Keeps working changes nice and tidy in the branch they belong to, you can push them, and they are easily recoverable from the ref log, unlike stashes.

Also, god help you when a stash fails to apply.

Re:This is how I git by IggleSniggle on Tuesday November 10, 2020 @08:40AM (#25045770)
I needed this comment today. I am an avid stasher, despite knowing the downsides. It’s just so convenient (until it’s not...at which point I usually give up and trash it, and yell at myself for not settling into a partial commit sooner).

But this workflow (which seems so very obvious in retrospect), keeps my current workflow, with so many benefits. The only place where it even requires extra steps is when you want to apply the stash to a different branch, and even there, it just feels right:

“Oh yeah, I was working on that feature over there, let’s pop it off and go put it on this feature over here.”

Since this generally requires careful diffing anyway to make sure things end up in the right place, there’s not much lost here, and without the downsides of stash.

Re:This is how I git by bitjson on Tuesday November 10, 2020 @10:31AM (#25047027)
If anyone is interested, there's a tiny utility I've used daily for years to do this: https://github.com/bitjson/wip

Each time you run `wip`, all current work is committed. When you run the squashing utility `naenae` (autocomplete: `nae + Tab`), the most recent line of "WIP" commits is saved to a `wip-archives/[branch]/[timestamp]` branch for safe keeping, the commits are all squashed in place, and you're left in your default git editor to define the commit message. It also handles unusual situations, like using `wip` for the first commit (in which case, `git reset HEAD^` will return an error).

Being able to set a sort of "WIP checkpoint" in the current working directory makes it really easy to start or back out of big changes, and it can be very useful to check back in past WIP commits to grab segments of code you previously threw away.

Re:This is how I git by FreeFull on Tuesday November 10, 2020 @08:10AM (#25045531)
Alternatively, instead of `git reset HEAD^` you could do `git commit --amend` to merge further changes into the latest commit
Re:This is how I git by bradstewart on Tuesday November 10, 2020 @09:59AM (#25046663)
This. I have these aliased as `git save` and `git unsave`, which makes it as convenient as `git stash`.
Re:This is how I git by corytheboyd on Tuesday November 10, 2020 @11:36AM (#25047856)
I do this all the time, it’s the only real way of saving state when you are abruptly asked to do something else