DEV Community

Discussion on: Five Git commands I started using that might be helpful to you

Collapse
marounmaroun profile image
Maroun Maroun

Since Git 2.23.0, you can use git restore. It's a huge improvement over the sometimes-misleading checkout command.

Collapse
murkrage profile image
Mike Ekkel Author • Edited on

In what way would you say checkout is misleading? I'd love to dive into that 😄

I did a quick search for git restore and it seems it's still experimental, so I wonder if it's a good idea to advice that. I'll definitely try it out the next time I need it, tho!

Collapse
marounmaroun profile image
Maroun Maroun

Sorry for the confusion.

I said "misleading" in the sense that it's used for various purposes - Using checkout you can:

  • Create a branch (with the -b flag)
  • Switch to a branch
  • Reset and revert file

Now, you can use git switch and git restore to avoid such confusion with the checkout command - switch -c creates a branch, switch switches to a branch, and restore is for reverting.

Thread Thread
murkrage profile image
Mike Ekkel Author

Yeah that makes more sense! I get what you are saying and I agree that having the specific command is much clearer. I'm still a little thrown off by the experimental part of the command. All in due time I suppose :)