Problem scenario
You have seen "git branch" and heard of branching strategies. What does "git branch" actually do? How can you use "git branch"?
Solution
In the context of version control or configuration management, branching is a fork of a codebase.
(Forking is the creation of an independent copy of a repository; a branch is the same except it is a copy of a repository within the same repository for the purpose of merging with the main or "trunk" branch. Forking usually involves publishing the repository. A branch will be available whereever its trunk is available. The repository may not be published.) A branch is a duplicate version of the Git repository that is created for testing, prototyping or developing. The "git branch" command allows you to list, create or delete branches of a Git repository. To understand what a branch of a code base is, try this from inside a git repository:
git branch --list
# *
To create a branch, from inside a git repository, run a command such as this:
git branch fun4whatever
# *
To delete a branch, from inside a git repository, run a command such as this:
git branch -D fun4whatever
# replace "fun4whatever" with the name of your git repository's branch.
* To install git, run sudo apt-get -y install git
for a Debian distribution or sudo yum -y install git
for a RedHat distribution.
You may want to do this first if you do not have a git repository:
git clone https://github.com/ContinualIntegration/portfolio.git
cd portfolio