Square-root
Square-root

Reputation: 883

Why branch when I have master locally?

A noob here. I've been reading for a few days about git and I understand branching and stuff but can you clarify this to me please.

What is the point of branching when I have a copy of a repository locally and I can just work on just the master which will not affect the master on the remote repository. Then I just push changes from my local master to the remote master?

Upvotes: 2

Views: 82

Answers (3)

Vraj Pandya
Vraj Pandya

Reputation: 621

The simple answer is to keep everything organized.

I usually keep a local master branch and a work branch. So that I know which code is perfect and ready to go. Then I branch out work with some features and/or bug fixes. I keep merging master with work time to time so it simply makes it easy for me to push my changes to remote.

I started this so if I got bored working on one thing I could easily jump to something else. I can just ignore the first task for a while and return to it when I get the "brain wave" for it.

You are perfectly in your rights to do what you wish on your local repository. It is a question of "To branch or Not to branch" and it will stay that way. When it comes to local branching I would simply suggest to "use the force".

So do whatever you feel that is productive.

Upvotes: 1

Alex
Alex

Reputation: 838

branches may be use for testing purpose i mean for developing and production you can define both for same project.

https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

https://git-scm.com/book/en/v1/Git-Branching-What-a-Branch-Is

Upvotes: -1

Daniel A. White
Daniel A. White

Reputation: 190905

Branches allow you and others to work on multiple things at the same time. Polluting master can cause problems if you ever need to patch a bug or have uncompleted code for a new feature that isn't ready for release. Plus, pushing it to GitHub is a nice way to backup your work.

Upvotes: 1

Related Questions