Skip to main content
March 23, 2026Dan Rodney/5 min read

Branches: Create, Switch, Push, Merge, & Delete

Master Git Branching for Professional Development Workflows

Why Git Branches Matter

Git branches enable parallel development workflows, allowing multiple developers to work on different features simultaneously without conflicts. This fundamental concept separates amateur from professional development practices.

Git Branches

Git enables you to branch out from your main codebase, creating parallel development paths that revolutionize how teams collaborate. This branching system provides unparalleled flexibility in your development workflow, allowing multiple developers to work simultaneously without interfering with each other's progress or the stability of your production code.

Git branches merge

Consider this real-world scenario that demonstrates the power of Git branches: You're deep into developing a complex new feature for your application when an urgent bug report comes in—something that needs to be fixed and deployed immediately. Without branches, you'd face a dilemma: either abandon your unfinished work or deploy unstable code. With Git branches, you simply switch back to your main branch, implement the hotfix, and deploy it to production. Then you seamlessly return to your feature branch to continue development. When your new feature is complete and tested, you merge it into the main branch, preserving both your urgent fix and your new functionality. This workflow prevents the chaos that often accompanies concurrent development efforts.

Core Git Branch Benefits

Parallel Development

Work on multiple features simultaneously without interfering with the main codebase. Switch between different development contexts instantly.

Safe Experimentation

Test new ideas and approaches without risk to production code. Easily discard failed experiments or merge successful ones.

Team Collaboration

Multiple developers can contribute to the same project without stepping on each other's work. Merge changes when ready.

Working on a Branch: Commit, Push, Pull, Etc.

Every Git operation you perform—whether committing changes, pushing to remote repositories, or pulling updates—occurs within the context of your current branch. This branch-specific behavior is fundamental to Git's design and critical to maintaining clean project history. Always verify you're on the correct branch before executing any Git commands, as working on the wrong branch is one of the most common sources of confusion and merge conflicts in team environments.

Branch Context Awareness

Every Git command you execute operates within the context of your current branch. Always verify which branch you're on before committing, pushing, or pulling to avoid unintended changes to the wrong branch.

See What Branch You're on

Visual Studio Code displays your current branch name in the bottom-left corner of the window. The default branch name varies by platform and Git configuration—while older repositories may show master, most modern repositories use main as the default branch name, reflecting current industry best practices around inclusive terminology.

Identifying Your Current Branch in VS Code

1

Locate Branch Indicator

Look at the bottom left corner of the Visual Studio Code window where the current branch name is displayed

2

Verify Branch Context

The default branch name is typically 'master' but confirm you're on the intended branch before making changes

Create a New Branch

  1. Click the current branch name in the bottom-left corner of the Visual Studio Code window.
  2. In the command palette that appears at the top of the window, select + Create new branch.
  3. Enter a descriptive name for your new branch and press Return (Mac) or Enter (Windows). Use clear, purposeful naming conventions like feature/user-authentication or bugfix/header-alignment to maintain project organization.

    You're now working on your new branch and ready to make commits that won't affect your main codebase.

Creating a New Branch in VS Code

1

Access Branch Menu

Click the current branch name at the bottom left of VS Code window to open the branch selection panel

2

Select Create Option

Choose '+ Create new branch' from the panel that appears at the top of the window

3

Name Your Branch

Type a descriptive name for your new branch and press Return (Mac) or Enter (Windows) to create it

4

Start Working

You're now on the new branch and ready to make commits specific to this development context

Switch to a Branch in Your Local Repo

Switching between local branches allows you to context-switch between different features or experiments instantly.

  1. Click the current branch name in the bottom-left corner of the Visual Studio Code window.
  2. From the branch list that appears in the command palette, select the branch you want to switch to. Visual Studio Code will instantly update your workspace to reflect that branch's state.

Local Branch Switching Checklist

0/3

Switch to a Branch in a Remote Repo

Working with remote branches enables collaboration with team members and access to work stored in your remote repository.

  1. First, fetch the latest branch information from your remote repository. In the Source Control panel vscode soure control icon, click the More Actions button vscode more actions icon, navigate to Pull, Push, and select Fetch.
  2. Click the current branch name in the bottom-left corner of the window.
  3. In the branch list, remote branches are prefixed with origin/ (or your remote's name). Select the remote branch you want to work with—Visual Studio Code will automatically create a local tracking branch.

Accessing Remote Branches

1

Fetch Remote Data

In Source Control panel, click More Actions button, navigate to Pull, Push and select Fetch to get latest remote branch information

2

Open Branch Panel

Click the current branch name at bottom left of VS Code to view all available branches

3

Identify Remote Branches

Remote branches are prefixed with 'origin/' in the branch list panel

4

Switch to Remote Branch

Select the origin/ branch you want to work with from the available options

Fetch Versus Pull

Fetch downloads the latest data from your remote repository without modifying your working files. This allows you to see what changes exist remotely before deciding how to integrate them.

Pull combines fetch and merge operations: it downloads new data from the remote repository and immediately attempts to merge those changes into your current branch. Use pull when you're confident about integrating remote changes.

Fetch vs Pull Operations

FeatureFetchPull
Data DownloadDownloads new data from remoteDownloads new data from remote
Local IntegrationDoes not merge into filesMerges data into your files
Working DirectoryLeaves files unchangedUpdates your working files
Safety LevelSafe, non-destructiveCan create merge conflicts
Recommended: Use Fetch when you want to see what changes are available without affecting your current work. Use Pull when you're ready to integrate remote changes into your local branch.

Merge a Branch

Merging integrates changes from one branch into another, typically combining feature work back into your main development branch.

  1. Switch to the target branch—the branch that will receive the merged changes. In most workflows, this means switching to your main or master branch. Click the current branch name in the bottom-left corner and select your target branch.

    Professional teams often use pull requests or merge requests instead of direct merges to maintain code quality through peer review processes.

  2. Ensure your working directory is clean by checking the Source Control panel vscode soure control icon for any uncommitted changes. Commit or stash any pending work before proceeding.
  3. Execute the merge by clicking the More Actions button vscode more actions icon in the Source Control panel vscode soure control icon and selecting Branch > Merge Branch.

  4. Choose the source branch you want to merge into your current branch.

    NOTE: Merge conflicts may occur when Git cannot automatically reconcile differences between branches. When this happens, refer to How to Handle Merge Conflicts for resolution strategies.

Branch Merging Process

1

Switch to Target Branch

Navigate to the branch that will receive the merged changes, typically the master branch

2

Verify Clean State

Ensure Source Control panel shows no uncommitted changes that need to be committed first

3

Access Merge Options

Click More Actions button in Source Control panel, then select Branch > Merge Branch from the menu

4

Select Source Branch

Choose the branch you want to merge into your current branch and confirm the merge operation

Merge Conflict Preparation

Merging branches may result in conflicts when the same code has been modified in different ways. Be prepared to resolve conflicts manually when they occur during the merge process.

Delete a Local Branch

Maintaining a clean branch structure improves repository navigation and reduces confusion. Delete branches that have served their purpose and been successfully merged.

  1. Switch away from the branch you want to delete—Git prevents deletion of the currently active branch as a safety measure.
  2. Access the branch management menu by clicking the More Actions button vscode more actions icon in the Source Control panel vscode soure control icon and selecting Branch > Delete Branch.

  3. Select the branch you want to delete from the list.

    Confirm the deletion when prompted. Remember that this only removes the local branch—remote branches require separate deletion if you want to clean up your remote repository as well.

Safe Branch Deletion Process

0/4

Key Takeaways

1Git branches enable parallel development workflows, allowing multiple features to be developed simultaneously without interfering with the main codebase or each other.
2Always verify your current branch before executing Git commands, as all operations (commit, push, pull) are performed within the context of the active branch.
3Visual Studio Code displays the current branch name in the bottom left corner, providing constant visibility into your working context.
4Remote branches are prefixed with 'origin/' and require fetching remote data before they become visible in your local branch list.
5Fetch downloads remote data without merging, while Pull downloads and immediately merges changes into your local files, potentially creating conflicts.
6Merging combines changes from one branch into another, typically merging feature branches into the master branch when development is complete.
7Branch deletion requires switching away from the target branch first, as you cannot delete the branch you're currently working on.
8The merge process may result in conflicts that require manual resolution when the same code has been modified differently in multiple branches.

RELATED ARTICLES