Git: Branches

When you commit a file to Git, you are committing it into the current branch.

Git allows you to work simultaneously on multiple, separate branches, different lines of development which represent forks of the main branch.

Git is very flexible: you can have an indefinite number of branches active at the same time, and they can be developed independently until you want to merge one of them into another.

Git by default creates a branch called master. It’s not special in any way other than it’s the one created initially.

You can create a new branch called develop by typing

git checkout -b develop

The git branch command lists the branches that the repository has.

When creating the new branch, that branch points to the latest commit made on the current branch. If you switch to it (using git checkout develop) and run git log, you’ll see the same log as the branch that you were previously.

Lessons this unit:

0: Introduction
1: Installing Git
2: Initialize a repository
3: Commit changes
4: ▶︎ Branches
5: Push and pull
6: Working with a remote
7: Solving conflicts
8: .gitignore