Git branch
A branch
in git
is a line of development within a repository. Git allows many branches and thus different lines of development within a repository. By default, we have the master branch. There are many reasons for branching; there are no hard-set rules about when to branch or when to work on just the master branch. Most of the time, we create a branch when there is a bug fix, a customer software release, or a development phase. In our example, let us create a branch that represents development, appropriately named the dev
branch:
(venv) $ git branch dev
(venv) $ git branch
dev
* master
Notice we need to specifically move into the dev branch
after creation. We do that with checkout
:
(venv) $ git checkout dev
Switched to branch 'dev'
(venv) $ git branch
* dev
master
Let's add a second file to the dev
branch:
(venv) $ echo "my second file" > mySecondFile.txt
(venv) $ git add mySecondFile.txt
...