0
0
Gitdevops~15 mins

Creating branches with git branch - Try It Yourself

Choose your learning style9 modes available
Creating branches with git branch
📖 Scenario: You are working on a project and want to try a new feature without affecting the main code. To do this safely, you will create a new branch in git. Branches let you work on different versions of your project separately.
🎯 Goal: Learn how to create a new branch in git using the git branch command and verify the branch creation.
📋 What You'll Learn
Create a new branch named exactly feature1 using git branch
Check the list of branches to confirm feature1 exists
Use the exact commands git branch feature1 and git branch
💡 Why This Matters
🌍 Real World
Developers use branches to work on new features or fixes without disturbing the main project code. This helps keep the project organized and safe.
💼 Career
Knowing how to create and manage branches is essential for collaboration in software development teams using git.
Progress0 / 4 steps
1
Initialize a git repository
Initialize a new git repository by running the command git init in your project folder.
Git
Need a hint?

Type git init to start a new git repository in your current folder.

2
Create a new branch called feature1
Create a new branch named feature1 by running the command git branch feature1.
Git
Need a hint?

Use git branch feature1 to create the branch without switching to it.

3
List all branches to verify creation
List all branches by running the command git branch to verify that feature1 branch exists.
Git
Need a hint?

Run git branch to see all branches in your repository.

4
Show the output confirming the new branch
Run the command git branch and observe the output. It should list feature1 and the current branch marked with an asterisk.
Git
Need a hint?

The output of git branch shows the current branch with * and lists all branches including feature1.