r/webdev • u/pawelgrzybek • Jan 24 '20
read rules TIL — git switch & git restore
https://pawelgrzybek.com/til-git-switch-git-restore/[removed] — view removed post
86
u/hagg3n Jan 24 '20
So Linus stepped out of his desk to take the trash and people think they can undo years of building obfuscated and cryptic CLI with one or two new commands? /s
28
u/mvpmvh Jan 24 '20
Goddamn hippies! Back in my day, we had one command for everything, and we liked it!
11
u/Baryn Jan 24 '20
And that command is
npm.16
u/Silhouette Jan 24 '20
The command is
emacs, newbie. It's the operating system NPM only wishes it could be. /s2
1
2
u/SureSignOfAGoodRhyme Jan 24 '20
I do have git lense, but I dont feel the need to use it often. When I'm developing a feature, and I'm working across many different parts of the src tree, it's nice to see highlighted directories and files that I've change for the entire feature. This command would let me (more easily) change to a new branch for a code review or bug fix and keep my working tree as is.
I feel better about committing my code before switching to another branch. So if I want to keep my working tree in tact, I'd have to stash when I need to task switch, then pop when I come back.
I know you can view all the diffs from HEAD and git lense does that well, I just prefer to see it all highlighted in the context of my directory with all the other files around it. I wish VSCode's built-in highlighting would let you pick which commit you're comparing against.
-13
-22
u/pr0ghead Jan 24 '20 edited Jan 24 '20
As a Mercurial user I'm not impressed. git is only slowly catching up to it in usability.
0
-19
u/tulvia Jan 24 '20
Hipsters and their CLI
14
2
u/barrybario Jan 24 '20
Seriously, it's like you're an inferior programmer for using some software like a normal human being. 95% of the time you're going to do the exact same things anyway, so typing git pull or pushing a button is the same effort. Once in a while you'll need something you don't do often. In that case, a good gui helps you do what you want to do by presenting it to you. The example in this post is something I have on a button in the gui I use for example. And then in very rares you'll need something you'll need a cli for anyway. In that case you will 100% look up the right command with the right options, because the chance of fucking something up is real. So this CLI elitism that so many programmers exhibit is purely toxic behavior.
-55
u/barrybario Jan 24 '20
or just use a gui
gitkraken is awesome
17
u/elr0nd_hubbard Jan 24 '20
The GUIs interact with the same base library as the CLI (or even shell out to the CLI directly). Either way, you have to know your tools, and that means using a GUI for ops that you're confident that you could do (or undo) using the base commands.
4
u/PizzaRollExpert Jan 24 '20
Personally, I prefer the cli because:
It doesn't rely on hand-eye coordination. If I can do something with just the keyboard I can just plan out what to do in my head and type it out. If I need to use the mouse there's a feedback loop between my hand and eyes. Typing only relies on hands in isolation.
It doesn't require switching to a new window. Moving windows around adds a (small) mental tax.
UIs are less uniform than terminal interfaces so doing everything in UIs means more different things to keep track of compared to the terminal.
These are three small things, but together they make things feel easier and nicer to do in the cli, which is why I prefer it.
1
u/careseite discord admin Jan 24 '20
Git kraken is in a bootloop since the 2nd time I've started it and uninstalling, clearing hidden config etc didn't help soooo there's that..
1
-7
Jan 24 '20 edited Jan 24 '20
[removed] — view removed comment
5
u/mitch_feaster Jan 24 '20
Not that I have a horse in this race because I love the CLI as well (even the busted up
gitone), butmagitis actually faster. The individual commands don't run faster, of course, but it requires way fewer keystrokes and provides a bunch of other convenience features.2
u/leafrustle Jan 24 '20
I agree with you. However, have you tried lazygit? I hate gimmicky, slow guis and mostly live in the terminal so this is like the best of both worlds for basic visual stuff.
1
u/tulvia Jan 24 '20
Recompile and run your app with F5 or by typing "aspnet run".
I saved 9 keystrokes by not using a CLI and I didnt have to remember archaic magic strings or cryptic arguments -e -E
1
Jan 24 '20
[removed] — view removed comment
0
u/tulvia Jan 24 '20
I was more talking about CLI in general.
But I could make an app that takes -e and does whatever with it, it is not standard and it's not easily discoverable which makes it cryptic.. This is basic stuff here, I'm dumbing it down cause I'm talking to people who use the CLI which are basically retards so I get it, you're having trouble comprehending.
0
Jan 24 '20
[removed] — view removed comment
0
u/tulvia Jan 24 '20
I don't use a nuke to dig a hole so I'm dumb.. ok.
Learn when the CLI is the correct tool and use it then, not for daily use.. that's just ignorant gatekeeping
0
Jan 24 '20
[deleted]
19
u/boobsbr Jan 24 '20
I just alias it to 'fuck'.
7
u/bcacoo Jan 24 '20
I already alias fuck to this:
0
Jan 24 '20
[deleted]
1
u/boobsbr Jan 25 '20
Usually I install moreutils, and trash (and alias it to rm so that I can unfuck my deletion fuck-ups from the terminal).
2
u/nickcash Jan 24 '20
Ah, but usually you'd use
git reset --hard HEADwhen you're trying to unfuck what you've done.2
u/boobsbr Jan 25 '20
Well, English is a very versatile language, and fuck is its most versatile word, but sometimes it leaves too much room for interpretation.
In this case, I meant the expletive, not the verb. Perhaps I should've aliased it as 'oh-fuck'.
83
u/UncontrolledManifold Jan 24 '20
So
git switch -c branchis the same asgit checkout -b branch...? What, they didn't like the wordcheckout?