Open Source Guide
Tutorials

Push Changes

Learn how to push your changes to GitHub

Push Changes

Pushing uploads your local commits to your GitHub repository.

What is Pushing?

Pushing sends your local commits to the remote repository (GitHub) so others can see your changes.


Step-by-Step Guide

Step 1: Verify Your Commits

# Check your commits
git log --oneline

# Make sure you're on the right branch
git branch

Step 2: Push to GitHub

# Push your branch
git push origin your-branch-name

# Example:
git push origin feature/add-dark-mode

First Time Pushing a New Branch

# Set upstream and push
git push -u origin your-branch-name

# After this, you can just use:
git push

What Happens When You Push?

  1. Git uploads your commits to GitHub
  2. Your branch appears on GitHub
  3. You can now create a pull request
  4. Others can see and review your changes

Common Scenarios

Scenario 1: First Push

git push -u origin feature/my-feature

# Output:
# Enumerating objects: 5, done.
# Counting objects: 100% (5/5), done.
# Writing objects: 100% (3/3), 300 bytes | 300.00 KiB/s, done.
# Total 3 (delta 0), reused 0 (delta 0)
# To https://github.com/username/repo.git
#  * [new branch]      feature/my-feature -> feature/my-feature

Scenario 2: Subsequent Pushes

# After setting upstream
git push

# Output:
# Everything up-to-date

Scenario 3: Push After New Commits

# Make more changes
git add .
git commit -m "Add: More improvements"
git push

Troubleshooting

Error: "Updates were rejected"

# Someone else pushed changes
# Pull the latest changes first
git pull origin your-branch-name

# Then push again
git push

Error: "No upstream branch"

# Set upstream and push
git push -u origin your-branch-name

Error: "Permission denied"

Check:

  • Are you pushing to your fork (not the original repo)?
  • Is your GitHub authentication set up correctly?
  • Do you have write access to the repository?

Verify on GitHub

After pushing:

  1. Go to your repository on GitHub
  2. You should see a banner: "your-branch-name had recent pushes"
  3. Click "Compare & pull request"

Next Steps

Your changes are now on GitHub! Ready to create a pull request. 🚀

Your Progress

0/12
0%