5 ms·
> When I first used Git it drove me almost to tears of rage and frustration. But I did get it under control. I don't love Git, but I use it every day, by choic
by chx 4y ago
>
When I first used Git it drove me almost to tears of rage and frustration. But I did get it under control. I don't love Git, but I use it every day, by choice, and I use it effectively.
Yes. For me the rescue was Charles Duan's git tutorial: Understanding Git conceptually. https://www.sbf5.com/~cduan/technical/git/ https://www.sbf5.com/~cduan/technical/git/
> you can only really use Git if you understand how Git works. Merely memorizing which commands you should run at what times will work in the short run, but it’s only a matter of time before you get stuck or, worse, break something.
The original claims
>
It is very hard to permanently lose work.
I disagree. So I run a git reset safety net https://gist.github.com/chx/85db0ebed1e02ab14b1a65b6024dea29 https://gist.github.com/chx/85db0ebed1e02ab14b1a65b6024dea29 it saved my bacon quite a few times. (Bonus git cd command. It's useful.)
- evanrelf 4y agoThat `git cd` command is a great idea! Thanks for sharing.
- stu2b50 4y ago> I disagree. Anything that ends up in a commit should be recoverable (on the same local git repository, that is), no? The main things that can forever clobber your work afaik is git checkout -- <path>, which will perhaps a little unintuitively just clobber over whatever is not committed.
- cryptonector 4y agoBasically, making `git reset --hard` and `git checkout -f` auto-stash would be great.
- chx 4y agoThat's what the script does for the first. Essentially.
- cryptonector 4y agoBut it could just be built in to Git. I mean: it should be.
- kjeetgill 4y agoIf I had to pick my version of this solution to fix 60% of git's learning curve problems: a) Don't tell people about stash. All Commits Everything. b) All commands that change the working directory or branches should fail on uncommitted work and ask you to git commit. It already does this for untracked changes. c) Show people show git branch BACKUP (requiring a commit) + git reset --hard BACKUP will always get you back to where you started safely.
- cryptonector 4y agoYes. Plus commands that alter dirty workspace files could just do a "stash" like thing.
- ziml77 4y agoThat script is a really smart idea! Now I'm thinking it's almost crazy that's not built in.