please stop using git checkout! Learn to use the right git commands

please-stop-using-git-checkout!-learn-to-use-the-right-git-commands

git checkout command exists since the beginning of git

It is used for these things:

  • creating new branch

git checkout -b new-feature upstream/main

  • switching branch

git checkout main

  • restoring unstaged changes

git checkout README.md

  • checking out code from other branch

git checkout v1.0.0 -- README.md

git checkout command confuses everyone who start using git

Why?

Because it mixes two concepts:

  • branches juggling
  • restoring files

That’s why new commands were added with Git 2.23 (August 2019, almost 5 years ago):

git restore can be used as a simple replacement on action on files.

the only noticeable changes between git switch and git checkout is that branch creation was done with git checkout -b name while it’s now git switch -c name

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
ai-enthusiasm-#10-–-summarize-pdfs-with-ai🗎

AI enthusiasm #10 – Summarize PDFs with AI🗎

Next Post
advancing-in-web-application-security:-exploring-advanced-login-security-and-cache-control

Advancing in Web Application Security: Exploring Advanced Login Security and Cache Control

Related Posts