Git Push Branches — Pushing and Managing Remote Branches
In the previous blog, we pushed our first commit to GitHub using SSH.
Now, let’s go a step further — adding new commits, creating branches, pushing them to remote, and learning how to list/manage local and remote branches.
Pushing Additional Commits
I added a new commit locally. At this point:
- Local
mainbranch → 2 commits - Remote
origin/main→ still 1 commit
To push the new commit:
git push origin main
✅ Equivalent to:
git push origin main:main
Since source branch and destination branch have the same name, you don’t need to write both.
After pushing, GitHub reflects the second commit.
Creating and Pushing a New Branch
Let’s create a branch:
git branch feature1
git switch feature1
Make some changes, commit, and now you have:
main→ continues from first commitsfeature1→ new branch with additional commit
Push with a Different Remote Name
If you want this branch to appear with a different name on GitHub (e.g., audiocall):
git push origin feature1:audiocall
- Left side (
feature1) → Local branch name - Right side (
audiocall) → Remote branch name on GitHub
Now GitHub will have a branch named audiocall, even though your local branch is feature1.
Listing Branches
Git provides several useful options with git branch:
Local Branches
git branch
Shows only your local branches.
All Branches (Local + Remote)
git branch -a
Lists both local and remote branches.
Remote Branches Only
git branch -r
Shows only remote branches.
Branch Tracking Information
git branch -vv
Displays each local branch along with its tracking information (which remote branch it is mapped to).
👉 In our case, no local branch is mapped to a remote branch yet. We’ll see how to set up tracking branches in the next blog.
Summary
- Use
git push origin branchto push commits. - Rename remote branch during push with
git push origin localbranch:remotebranch. - Use
git branch,-a,-r, and-vvto explore local and remote branches. - Tracking branches are not set by default — we’ll cover them next.
Coming Up Next
In the next blog, we’ll see how to set up tracking branches so that local and remote branches stay in sync without writing long push commands every time.
Keep Learning 🚀
👉 Subscribe to Learning Ocean – Subscribers get coupon codes for my courses, early access to blogs and courses, and even exclusive YouTube videos.
👉 My YouTube Channel – More videos, more fun, and lots of learning!
👉 📺 Watch this topic in video form
Stay curious, keep coding, and let’s make learning fun together! 🎉