firstcontributions / first-contributions

πŸš€βœ¨ Help beginners to contribute to open source projects
https://firstcontributions.github.io
MIT License
44.44k stars 77.63k forks source link

Add git branch and git checkout Commands #87677

Open yehiarasheed opened 3 weeks ago

yehiarasheed commented 3 weeks ago

I noticed that in the README.md, you explained git branching using git switch branch-name instead of git branch branch-name then git checkout branch-name

🐞 Problem I'm proposing that we add using git branch branch-name then git checkout branch-name as an additional explanation or option (feature) so that the project may provide a fuller description.

🎯 Goal This change is important to me to provide first-time contributors with actual Git knowledge, especially that GUIs for Git even in IDEs such as IntelliJ for example and other platforms rely and explicitly list checkout as an option, which the contributors would not understand after contributing to the post. Although I do agree that git switch branch-name is indeed simpler and quicker for new contributors to learn but adding the two other git commands would not hurt the core of the project.

Esh07 commented 3 weeks ago

Youp. Back in days it was powerful to do it like that way as you referring this https://stackoverflow.com/a/7987711.

but why make doc more longer when we have updated command to make process little faster πŸ˜„ .

Good Read

Git switch and git checkout are both used to change branches, but they have some differences in syntax and behavior. Git switch is a newer command that is more focused on branches, while git checkout is an older command that can do other things besides switching branches.

Git checkout has a more versatile syntax than git switch, but it can also be more confusing and error-prone if you don’t understand its behavior.

https://kodekloud.com/blog/git-switch-vs-checkout/

yehiarasheed commented 3 weeks ago

Good read I agree, I also think we shouldn't make the docs longer so that it isn't intriguing for new contributors. However, we should at least inform them with the term branching and that checking out is another term for switching so that they are more ready to go contribute and work with IDEs and their terminology straight after using the repo, if you know what I mean. Even in one additional line or something so that the docs aren't longer but it is something they should know as a term.

Habeebah157 commented 3 weeks ago

Hello, I agree with you, I think it could help beginners understand what the git switch actually does. I was thinking something like this: To create a new branch, use the following command:

git branch branch-name

After creating the branch, switch to it with:

git checkout branch-name

Alternatively, you can create and switch to a new branch in one step using the git switch command:

git switch -c your-new-branch-name

.

yehiarasheed commented 3 weeks ago

Hello @Habeebah157, I'm happy that you agree with the concept and if you check the commits I made in PR #87678 you'll see that I did the exact same thing except that I reversed it so that the switch command is right on top and if a beginner wants to go to the git branch branch-name then git checkout branch-name then they go for the second option which I made obvious using a H3 in Markdown. Again, your implementation is great since it actually takes them to do the basic commands and then they learn the newer, easier command which I agree with to be honest. Check out my version here.