When working with Git and GitHub, creating and pushing branches is a routine — and powerful — part of modern development workflows. Whether you’re working on a new feature, fixing a bug, or collaborating with others, pushing a new branch allows you to keep your work organized and isolated from the main codebase.
In this blog, you’ll learn exactly how to push a new branch to GitHub using Git.
🧱 Prerequisites
Before you begin, make sure:
- You have Git installed
- You’ve cloned the repository locally
- You’re authenticated with GitHub (via SSH or a personal access token)
✅ Step-by-Step: Push a New Branch to GitHub
1. Create a New Branch
In your terminal or Git Bash, navigate to your repository and run:
git checkout -b your-branch-name
This creates and switches to a new branch.
Example:
git checkout -b feature/login-form
2. Make Changes and Commit
Edit your code or add new files. Then, stage and commit the changes:
git add .
git commit -m "Add login form feature"
3. Push the New Branch to GitHub
Use the following command to push your new branch:
git push -u origin your-branch-name
Example:
git push -u origin feature/login-form
origin
refers to the default remote GitHub repository.-u
sets the upstream so futuregit push
orgit pull
commands default to this branch.
4. Verify on GitHub
Go to your GitHub repository in the browser. You’ll see a notification suggesting you to “Compare & pull request” for your newly pushed branch.
From here, you can:
- Open a pull request
- Review code
- Merge it into the main branch after review
🧠 Pro Tips
- Use clear and descriptive branch names, like
bug/fix-auth
,feature/signup
, orhotfix/payment-error
. - Always pull the latest changes from
main
before creating a new branch to avoid conflicts:git checkout main git pull origin main git checkout -b your-new-branch
- You can check all local branches with
git branch
and all remote branches withgit branch -r
.
🏁 Conclusion
Pushing a new branch to GitHub is a fundamental skill for collaborative and versioned development. With just a few Git commands, you can safely isolate work, contribute features, and collaborate through pull requests — all without disrupting the main codebase.