How to Push a Specific Branch in Git
Pushing specific branches in Git allows you to control exactly which branches are shared with remote repositories, avoiding accidental pushes of work-in-progress branches. As the creator of CoreUI with over 25 years of software development experience, I regularly push feature branches individually when preparing pull requests and managing multiple parallel development streams. Explicitly naming branches prevents pushing unintended changes and gives you precise control over what gets shared.
Use git push origin branch-name to push a specific branch to the remote repository without affecting other branches.
# Push specific branch to origin
git push origin feature-login
# Push current branch explicitly
git push origin HEAD
# Push and set upstream tracking
git push -u origin feature-dashboard
# Push specific branch to different remote
git push upstream main
# Push local branch to different remote branch name
git push origin local-branch:remote-branch
# Check which branches would be pushed
git push --dry-run origin feature-branch
When you specify a branch name with git push origin branch-name, only that branch is pushed to the remote repository. Use -u or --set-upstream flag to establish tracking between your local branch and the remote branch, enabling git pull and git push without arguments in the future. You can push a local branch to a different name on the remote using the local:remote syntax. This approach prevents accidentally pushing experimental or incomplete branches.
Best Practice Note:
In CoreUI development, we always push feature branches explicitly by name to ensure only completed work reaches the remote repository. This practice prevents incomplete features from affecting other developers and maintains clean separation between different development streams in our component library projects.



