Branching Demo
Last updated
Last updated
Nearly every VCS has some form of branching support.
Branching means you diverge from the main line of development and continue to do work without messing with that main line.
In many VCS tools, this is a somewhat expensive process, often requiring you to create a new copy of your source code directory, which can take a long time for large projects.
Some people refer to Git’s branching model as its “killer feature,” and it certainly sets Git apart in the VCS community.
The way Git branches is incredibly lightweight, making branching operations nearly instantaneous,
Switching back and forth between branches generally just as fast.
Unlike many other VCSs, Git encourages workflows that branch and merge often, even multiple times in a day.
Understanding and mastering this feature gives you a powerful and unique tool and can entirely change the way that you develop.
Some people refer to Git’s branching model as its “killer feature,” and it certainly sets Git apart in the VCS community!
The idea is that your branches are at various levels of stability; when they reach a more stable level, they’re merged into the branch above them. Again, having multiple long-running branches isn’t necessary, but it’s often helpful, especially when you’re dealing with very large or complex projects
Let’s go through a simple example of branching and merging with a workflow that you might use in the real world. You’ll follow these steps:
Do some work on a website.
Create a branch for a new user story you’re working on.
Do some work in that branch.
At this stage, you’ll receive a call that another issue is critical and you need a hotfix. You’ll do the following:
Switch to your production branch.
Create a branch to add the hotfix.
After it’s tested, merge the hotfix branch, and push to production.
Switch back to your original user story and continue working.
Let us create a file and put some contents in it, as shown in the commands below