How to Switch Branches and Commit Changes in Git

This beginner-friendly GitHub video teaches the basics of switching branches and committing changes in git, with guidance from the GitHub team.

How to Switch Branches and Commit Changes in Git

In this video, the GitHub team demonstrates essential git branch management skills:

Full Git Workflow Demonstrated

  1. Switch Back and Forth Between Branches
    • git switch main
    • git switch your-feature-branch
  2. Edit Files
    • Make the code or documentation changes you need.
  3. Check the Working Directory
    • git status shows which files have changed and which are staged for commit.
  4. Stage Your Changes
    • git add <filename> stages your changes for the next commit.
  5. Commit Your Work
    • git commit -m 'Describe your changes' records your edits in git history.

This tutorial is ideal for new developers starting with git and GitHub, illustrating a smooth workflow for making and recording changes in a project repository.

Learn More