Creating Branches
Viewing Branches
While inside of a git project directory git branch
command is very useful.
Navigate your terminal to the py-demo-web-logs
project you cloned in the previous walkthrough.
Run the command git branch
.
Running the git branch
command without an argument will show you the current branch you are working on and any additional local branches in your local repository (this project only has one branch in the local repository).
Creating a new Branch
The main.py
file within this project currently contains a bug. You are going to create a new branch to fix the bug and stage that change for commit.
You will need to:
- create a new branch
- view the new branch
Run the command git branch bug-fix
.
Check that the branch has been created using the git branch
command. Notice the new branch was created, but the currently checked out branch is still the master
branch as indicated by the asterisk and green text.
Recap:
- View existing branches with
git branch
- View all branches (including remote) with
git branch -a
- View all branches (including remote) with
- Creating a new branch with
git branch [new-branch-name]