0
0
Gitdevops~15 mins

Deleting branches in Git - Mini Project: Build & Apply

Choose your learning style9 modes available
Deleting branches
📖 Scenario: You are working on a project with multiple branches in Git. Some branches are no longer needed and should be deleted to keep the repository clean and organized.
🎯 Goal: Learn how to delete local and remote Git branches safely using the correct commands.
📋 What You'll Learn
Create a local branch named feature1
Create a local branch named feature2
Delete the local branch named feature1
Delete the remote branch named feature2
💡 Why This Matters
🌍 Real World
Deleting unused branches helps keep your Git repository clean and easier to manage, especially when working with teams.
💼 Career
Knowing how to manage branches is essential for developers and DevOps engineers to maintain code quality and collaboration.
Progress0 / 4 steps
1
Create local branches
Create two local branches named feature1 and feature2 using the git branch command.
Git
Need a hint?

Use git branch branch_name to create a new branch.

2
Delete local branch
Delete the local branch named feature1 using the safe delete command git branch -d feature1.
Git
Need a hint?

Use git branch -d branch_name to delete a local branch safely.

3
Delete remote branch
Delete the remote branch named feature2 using the command git push origin --delete feature2.
Git
Need a hint?

Use git push origin --delete branch_name to delete a remote branch.

4
Verify branch deletion
Use git branch to list local branches and git branch -r to list remote branches to verify that feature1 and feature2 are deleted.
Git
Need a hint?

Run git branch and git branch -r to see local and remote branches.