DEV Community

Cover image for How to Easily Manage Work Across Multiple Git Branches
Saif Uddin
Saif Uddin

Posted on

How to Easily Manage Work Across Multiple Git Branches

Managing multiple branches in Git can be efficient with a good workflow and some Git features. Here’s a guide on working with multiple branches simultaneously:

1. Create and Switch Between Branches

  • Use git branch to create new branches:
git branch branch-name
Enter fullscreen mode Exit fullscreen mode
  • Use git checkout or git switch to switch between branches:
git checkout branch-name
or
git switch branch-name
Enter fullscreen mode Exit fullscreen mode

2. Work on Multiple Branches Simultaneously

  • In most cases, you’ll work on one branch at a time. However, for simultaneous work, you can:

  • Open different branches in separate terminal windows/tabs.

  • Use multiple text editor windows (e.g., VS Code allows you to open multiple folders in the same workspace).

3. Stash Changes to Switch Branches Temporarily

If you need to switch branches without committing your changes, you can use

git stash
git checkout other-branch

# Work on the other branch...
git checkout initial-branch
git stash pop  # Retrieve the stashed changes
Enter fullscreen mode Exit fullscreen mode

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay