Jayy
Jayy

Reputation: 2436

Difference between Merging and Branching

I am new to version control. I often hear these words Merging and Branching. I also see different developers working in different branches.

Can someone explain the flow on this. What is the difference between Merging and Branching. When to go for Merging and Branching

Upvotes: 2

Views: 2268

Answers (2)

linquize
linquize

Reputation: 20396

In the concept of git, Branch is just a pointer to a commit, and will be advanced to the new commit when you make new commit to that branch. Git has 2 types of branches: local and remote. git can merge any single commit, not only the head of a branch. I take the most simple merging workflow as an example. 2 developers are working on a project. They are working independently based on the same version. They share the master (main) branch via a server when they complete. The first developer commit changes and push to the remote branch first. The second developer then synchronizes the changes by pulling changes made by the first developer. A merge commit will be automatically created.

Upvotes: 0

VonC
VonC

Reputation: 1329542

Branching is about isolating a development effort in a specific history, parallel to the main one.
See "When should you branch?": you branch when you cannot commit on the current branch (because it would break the work of your colleagues)

Merging is about reconciling two different branches.
You merge when you want to take into account in your branch the changes of the other branch you need to merge.

The workflow depends on the tools.

SVN offers either merge-based development or trunk-based development.

Tools with easier branching capabilities (like Git for instance) offer a workflow based on the various development lifecycle steps:

git workflow

Upvotes: 3

Related Questions