AdamNYC
AdamNYC

Reputation: 20415

Advantages of branching in Git (for an SVN user)

I have a project using Git. My co-worker comes from the SVN world and hesitates when checking out a new branch on his local repository. He would work on his local master and select files to push to remote repository.

How should I convince him of the advantages of branching? For example, what kinds of trouble might he run into when not checking out branches?

Thank you.

Upvotes: 3

Views: 408

Answers (2)

ralphtheninja
ralphtheninja

Reputation: 132978

There are several advantages with branching in git.

You can create a branch and name it whatever you like, without clashing into other peoples branches. You can name it "temp" or "test" without having to care that someone else has a branch called temp or test. Branch names are always local, until you decide to share them with others.

Branching in git is cheap and fast. The only overhead is a 41 bytes file containing a SHA1 hash.

You need no connection with a server in order to create a branch.

Branching in git is great for doing experimental stuff. If you want to go completely nuts and try out weird things, create a new branch and rock n roll. If you're not happy with the experiment simply delete the branch.

However, it seems your colleague doesn't understand branching in general and this is obviously a VCS agnostic question. Why use branches at all? The most obvious reason is to create a seam, i.e. create a space where you can work in isolation, without having to care about other peoples changes. This goes both ways too, you don't want to mess around with experimental stuff on the main branch.

Upvotes: 2

Michael Durrant
Michael Durrant

Reputation: 96454

Question: 58393457 (Your question)
Answer: 1 (i.e. same answer applies to all: better communication).

Set aside time to talk about it. Let him know that you are excited that he knows the different system that are out there. Ask him what he think the advantages of git are over svn. What about things that he sees as disadvantages.

Personally I have been using both the past year and have heard a lot of "svn works fine for me/us", "never given us a problem", etc. In many cases the person is both unaware of the way git works and also unwilling to change to a tool that is clear favored by the industry and by smart people that I follow.

Before talking about branching - which is often a big hurdle because the same word really means different things in the different systems, I would try and talk about the d in dvcs and what is different about that. Talk about the ability to commit, rollback, etc. to your own private repository without having the remote server available. With svn everything is in a big "uncommitted" pile until you are on-line. With git you can both do commits offline and also, when online, you can choose when to push those commits up. It's tough because some of the very ways of working with git are methods that would not work well with svn, so former svn user may not use them appropriately.

Finally branches. I would ask the question "do we still do branches the same way (i.e. for the same reasons) as we did in svn. The answer should be absolutely not. When I am collaborating on a project I usually am added and then do the git pull-commit-push sequence to do my work and keep in synch with others. Actually knowing git well, I also make sure I do git pull before starting a session to make sure I am up-to-date at that point and have no conflicts.

Branches are very valuable in git. However I usually save that kinda of activity for when I am either doing a version upgrade or I am doing work on a separate and distinct module for an extended period of time. Usually something that is going to take weeks or months rather than hours and days. Usually that is. Certain circumstances can lead to a different usage but the above is the norm for me for projects and organizations that I've worked with and for.

In some ways the actual answer to your question of "advantages of branching in git?" is "You don't have to use them nearly as much"

Upvotes: 2

Related Questions