firstcontributions / first-contributions

🚀✨ Help beginners to contribute to open source projects
https://firstcontributions.github.io
MIT License
44.61k stars 77.95k forks source link

If "git switch" is not recognized as a git command, provide alternative instructions #82152

Open jennie-jd opened 6 months ago

jennie-jd commented 6 months ago

🐞 Problem

My machine gave me an error that "git: 'switch' is not a git command. See 'git --help'".

🎯 Goal

After reading the git help menu, I discovered that git branch + git checkout is an alternative way of creating a new branch and switching to it, so adding these instructions will help people like me.

💡 Possible solutions

Add additional instructions:

If the following does not work: git switch -c your-new-branch-name

Consider using git branch and then git checkout: git branch your-new-branch-name git checkout your-new-branch-name

Or, a combined instruction: git checkout -b your-new-branch-name

📋 Steps to solve the problem

Esh07 commented 6 months ago

Here is good read https://ioflood.com/blog/git-switch-vs-checkout-pros-and-cons/

Git Switch and Git Checkout are both used for switching between different branches in a repository. However, Git Checkout is a versatile command also capable of discarding changes and creating new branches, while Git Switch is a newer, more specialized command focused solely on switching and creating branches.

It sound like using old git version < 2.27.0.

Check git version git --version

jennie-jd commented 6 months ago

Here is good read https://ioflood.com/blog/git-switch-vs-checkout-pros-and-cons/

Git Switch and Git Checkout are both used for switching between different branches in a repository. However, Git Checkout is a versatile command also capable of discarding changes and creating new branches, while Git Switch is a newer, more specialized command focused solely on switching and creating branches.

It sound like using old git version < 2.27.0.

Check git version git --version

Thanks, very helpful materials. That being said, I submitted a PR with some added information about git checkout, but the repo owner does not seem to be active in reviewing the PRs, so I am still waiting for his review.

Esh07 commented 6 months ago

Here is good read https://ioflood.com/blog/git-switch-vs-checkout-pros-and-cons/

Git Switch and Git Checkout are both used for switching between different branches in a repository. However, Git Checkout is a versatile command also capable of discarding changes and creating new branches, while Git Switch is a newer, more specialized command focused solely on switching and creating branches.

It sound like using old git version < 2.27.0. Check git version git --version

Thanks, very helpful materials. That being said, I submitted a PR with some added information about git checkout, but the repo owner does not seem to be active in reviewing the PRs, so I am still waiting for his review.

There is only one maintainer so it may take while to be merged. Mine also pending there.

Gokilp commented 5 months ago

check out your github version