Live data from Hacker News

New in Git: switch and restore

banterly.net

21–30 of 550 posts

Re: New in Git: switch and restore

#21
post #4

You don't need -- as much in the "git restore" example. With git checkout it may be necessary to separate the branch and the paths with "--" but since "git restore" does not take a branch (except with -s), doing this is totally fine git restore test.txt

It's usually not necessary for checkout either

Re: New in Git: switch and restore

#22
post #17

TL;DR because 'checkout' was found to be confusing, as of git 2.23 the switch command can switch to branches or commits (git switch master, git switch 0c38cf) and the restore command restores files (git restore pufferfish.txt).

Instead of one confusing command we now have three confusing commands.

Re: New in Git: switch and restore

#24
post #17

TL;DR because 'checkout' was found to be confusing, as of git 2.23 the switch command can switch to branches or commits (git switch master, git switch 0c38cf) and the restore command restores files (git restore pufferfish.txt).

Instead of one confusing command we now have three confusing commands.

I don't find switch or restore confusing? And also I never found checkout confusing, but that might only have been because I never realized it had multiple functions. I've been using it for both things (switching and restoring) for years, but I remember starting to read the article and thinking: how did I never notice this is the same command for two completely different things?! Maybe I used to know and now it's just not something I think about anymore? Either way, I can see how checkout can be seen as odd, but why switch or restore?

Re: New in Git: switch and restore

#25
post #4

You don't need -- as much in the "git restore" example. With git checkout it may be necessary to separate the branch and the paths with "--" but since "git restore" does not take a branch (except with -s), doing this is totally fine git restore test.txt

It's usually not necessary for checkout either

Not typing it with "checkout" gets in the way of good tab completion. At work we have at least tens of thousands of branches and if I hit tab after "git checkout file_path_prefix", my shell is going to freeze for a while, while tab completion is going over remote branches.

Re: New in Git: switch and restore

#26

I used to know lot of terminal commands but I'm seriously falling behind due to jetbrains integration which covers 99% of my daily use case. Together with local history, I've never "lost" work in years. Never heard of switch /restore and will probably forget about it the next time I'm on the terminal. Rebase and interactive Rebase is so well integrated for my use cases and I feel much more productive without having t…

I currently use a third-party git GUI (GitKraken atm) but I also use jetbrains products, am I missing out by not using the integrated git functionality? If so, is there a tutorial or guide you could recommend, or is it all fairly self-explanatory?

Re: New in Git: switch and restore

#27
post #19

Another difference is that with git checkout you can create and switch to the new branch in one command using the -b flag: git checkout -b new_branch You can do the same with the new one, but the flag is -c: git switch -c new_branch A good example why developers should not try to be designers. Even of talking about "API/CLI design.

Developers/designers are always torn between the competing priorities of preserving consistency and making a new interface the best it can be.

Re: New in Git: switch and restore

#28
post #25

Earlier quoted context omitted.

It's usually not necessary for checkout either

Not typing it with "checkout" gets in the way of good tab completion. At work we have at least tens of thousands of branches and if I hit tab after "git checkout file_path_prefix", my shell is going to freeze for a while, while tab completion is going over remote branches.

How do you end up with that many branches? It sounds like you keep every feature branch around forever. Keeping one around for a few months I get (although personally the sooner they're gone after rebasing or cherry-picking them the better), but this sounds like a full on history of every branch ever.

Re: New in Git: switch and restore

#29
post #25

Earlier quoted context omitted.

It's usually not necessary for checkout either

Not typing it with "checkout" gets in the way of good tab completion. At work we have at least tens of thousands of branches and if I hit tab after "git checkout file_path_prefix", my shell is going to freeze for a while, while tab completion is going over remote branches.

[deleted]

Re: New in Git: switch and restore

#30
post #19

Another difference is that with git checkout you can create and switch to the new branch in one command using the -b flag: git checkout -b new_branch You can do the same with the new one, but the flag is -c: git switch -c new_branch A good example why developers should not try to be designers. Even of talking about "API/CLI design.

Apple and GNOME are even better examples of why designers should not try to be designers. Now what options do we have left?
Post reply on HN