2 ms·
> It should have a different command for that functionality. It does in today's git. Rather than using `git checkout` you can migrate to using the two split co
by WorldMaker 4y ago
> It should have a different command for that functionality.
It does in today's git. Rather than using `git checkout` you can migrate to using the two split commands `git switch` (switches branches, generally safe) and `git restore` (restores files, generally "dangerous"). `git restore` also has the benefit that the some of the most dangerous commands at that point have similar names: restore, revert, and reset.
It will take a while for people's `git checkout` muscle memory to be replaced with `git switch` and `git restore` (and `git restore` is still marked as "experimental" despite being stable for quite a few git releases now, though that "experimental" suggestion seems to be mostly earmarked for people thinking to use `git restore` in automated scripts than it is for human users), but the command split is a very good thing for git user experience.
(I've mostly gotten used to `git switch` at least and have stopped using `git checkout` in my own work.)