News for hackers. Stuff that matters.
Re:Git 2.19.0 released by epicide on Wednesday September 12, 2018 @10:50AM (#17969330)
"git checkout -" is even better if you alias "checkout" to "co" since it just becomes "git co -".

Stash has to be my favorite (especially with "-u" AKA "include untracked").

I'm generally very comfortable doing even advanced stuff in git, but still get paranoid about some things. Especially when I'm trying to troubleshoot something for someone else.

Being able to stash away current changes in a place that is separate from any particular branch is invaluable.

I often show stash to people that make a habit of copying their entire project directory before doing something they aren't sure about (backups aren't inherently a bad idea, but that's why you push early and often).

Re:Git 2.19.0 released by napsterbr on Wednesday September 12, 2018 @12:10PM (#17970204)
> "git checkout -" is even better if you alias "checkout" to "co" since it just becomes "git co -".

And even better if you alias `git` to `g`!

Re:Git 2.19.0 released by jacobsenscott on Wednesday September 12, 2018 @12:53PM (#17970704)
Just go all out - alias g-='git checkout -'
Re:Git 2.19.0 released by epicide on Wednesday September 12, 2018 @02:40PM (#17971718)
Aliasing 'gg' to that would actually be pretty good. Unless you really need git gui.
Re:Git 2.19.0 released by pellucide on Wednesday September 12, 2018 @02:49PM (#17971814)
alias gb='git checkokut -'

gb for go back.

Re:Git 2.19.0 released by captn3m0 on Wednesday September 12, 2018 @03:06PM (#17972014)
Is there any good way to keep track of stashes? I keep stashing stuff that I forget about and end up rewriting 2 weeks later.
Re:Git 2.19.0 released by nimrody on Wednesday September 12, 2018 @03:20PM (#17972166)
Yes. Use a local branch. They are cheap to create. You can name the branch and, of course, write a descriptive commit message.

Stashes are for quick save and restore. Branches are way more powerful.

Re:Git 2.19.0 released by ramses0 on Wednesday September 12, 2018 @04:12PM (#17972729)
Hard agree here. Better to make "git my-stash working-on-foo" alias which makes a separate branch. Stashes have become an anti-pattern for me after having too many fail to reapply or drift out of date.
Re:Git 2.19.0 released by emmelaich on Wednesday September 12, 2018 @07:05PM (#17974316)
I have some aliases sl (stash list) and pop/drop for git stash pop/drop.

Also make a habit of saving your stashes with a meaningful label.

But yeah, like others suggest -- use branches.

Re:Git 2.19.0 released by ishwarn on Wednesday September 12, 2018 @06:51PM (#17974235)
I've made it a habit to `git stash list` and `git stash show -p stash@{2}` when I want to inspect the stashed changes.
Re:Git 2.19.0 released by hasperdi on Thursday September 13, 2018 @05:22AM (#17977188)
Git worktree changed my life. I can quickly switch branches and work on multiple branches at the same time.