To Branch or not to Branch?

see Recipe Book project - https://www.codecademy.com/courses/learn-git/projects/recipe-book

When and why should we create branches (either when working on a cloned repo with others, or our own projects)? I want to challenge my own perception that just cloning a repo and working on it is enough with all the standard git processes: edit, stage, commit; or just working on our own personal projects (without cloning) is enough.

Regardless of the way we do this (either cloning and creating branches, or just working on our own projects in our computers), is there a “best” way to go about this?

If I am confusing something, let me know and letme know where I am wrong. Thanks!

Hey @maureen_to!
You should create a new branch when you are making major changes to your project or just creating a new feature that might break something. So, for example, if I’m refactoring all my code, deleting large chunks and replacing it with smaller, better code, then I would want to do that on an alternative branch so I can make the changes without worrying about breaking something by accident.

I’m exactly sure what you’re asking in your second question… the best way to go about what?

4 Likes

That makes sense! Thank you - your answer answered my second question.

1 Like

For test purposes, I cloned a repo and didn’t create a new branch. Made changes to master branch (local repo) and now I wished to push it. The command “git push origin master” fatal errors. Does this mean, a new branch has to be created in your local clone ?