Version Control
Git: Moving ahead
Git: Moving ahead
  • Group 1
    • Resolving Merge Conflict
      • Create master
      • Create a branch
      • Merge them
  • Group 2
    • Branching Demo
      • Create issue53 branch
      • Commit a change
      • Check out master
      • Create a hotfix
      • Merge Hotfix
      • Delete the hotfix
      • Switch back to issue 53
  • Group 3
    • Adding Collaborators
      • Send invite
      • Accept Invite
Powered by GitBook
On this page
  • Presentation
  • Branching in a Nutshell
  • The idea behind branching
  • Let us work on a scenario
  • Let us create a repo to begin with
  1. Group 2

Branching Demo

PreviousMerge themNextCreate issue53 branch

Last updated 1 year ago

Presentation

Branching in a Nutshell

Nearly every VCS has some form of branching support.

  1. Branching means you diverge from the main line of development and continue to do work without messing with that main line.

  2. 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.

  3. Some people refer to Git’s branching model as its “killer feature,” and it certainly sets Git apart in the VCS community.

  4. The way Git branches is incredibly lightweight, making branching operations nearly instantaneous,

  5. Switching back and forth between branches generally just as fast.

  6. Unlike many other VCSs, Git encourages workflows that branch and merge often, even multiple times in a day.

  7. 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 behind branching

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 us work on a scenario

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:

  1. Do some work on a website.

  2. Create a branch for a new user story you’re working on.

  3. 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:

  1. Switch to your production branch.

  2. Create a branch to add the hotfix.

  3. After it’s tested, merge the hotfix branch, and push to production.

  4. Switch back to your original user story and continue working.

Let us create a repo to begin with

Let us create a file and put some contents in it, as shown in the commands below

mkdir gitdemo1
cd gitdemo1
git init
echo "this is my code file" > file1.txt 
cat file1.txt
git add .
git commit -m C0
echo "this is line 1" >> file1.txt
git commit -am C1
echo "this is line 2" >> file1.txt
git commit -am C2
git log --oneline
progressive-stability branching