If you’re working on a local project and want to back it up, share it, or collaborate with others — you’ll need to know how to push to GitHub. Whether you’re using the terminal, Visual Studio Code, or even a Jupyter Notebook, GitHub makes it easy to upload your code to a remote repository.
From beginner developers to seasoned pros, understanding GitHub is fundamental to the development workflow.
🧠 What Does “Push to GitHub” Mean?
Pushing to GitHub refers to the process of uploading code from your local repository to a remote GitHub repository. This ensures your latest changes are version-controlled and accessible to collaborators.
⚙️ Prerequisites Before Pushing Code
Before you do anything, you must:
- have Git installed on your system
- need a GitHub account
- initialize a Git repository locally, or clone one
- set up a remote origin that links your local repo to a GitHub repo
Initialize Git (if needed):
git init
Connect your repo to GitHub:
git remote add origin https://github.com/yourusername/repo-name.git
Learn more about Git vs GitHub here!
💻 How to Push Code to GitHub from Terminal (macOS, Linux, Windows)
Here’s a simple flow:
cd your-project-folder git init git add . git commit -m "Initial commit" git remote add origin https://github.com/yourusername/repo-name.git git branch -M main git push -u origin main

📂 How to Push a Folder to GitHub
If your project exists as a folder and hasn’t been versioned yet:
- Navigate to your folder in terminal
- Run the git init → git add . → git commit sequence
- Connect to GitHub remote
- Push using:
git push -u origin main
📄 How to Push a File to GitHub from Terminal
To push a single file:
git add filename.py git commit -m "Add single file" git push
🧱 How to Push to GitHub From VSCode
- Open your project folder in Visual Studio Code
- Go to the Source Control panel (left sidebar)
- Click Initialize Repository (if not done already)
- Stage changes, enter a commit message, and click the ✅ icon
- Click the “Publish to GitHub” button or use terminal to push:
git push -u origin main

🧠 How to Push Code to Existing GitHub Repository
If your repo already exists on GitHub:
git remote add origin https://github.com/user/repo.git git branch -M main git push -u origin main
You can also clone the repo first, then push:
git clone https://github.com/user/repo.git cd repo git add . git commit -m "Your changes" git push
🌱 How to Push a New Branch to GitHub
To create and push a new branch:
git checkout -b feature-branch git push -u origin feature-branch
After that, your branch will appear on GitHub under “Branches.”

⚙️ How to Push Code to GitHub from Visual Studio
In Visual Studio (not VSCode):
- Click “Git > Commit or Stash…”
- Type commit message, hit Commit All
- Select “Push to GitHub” option
- Authenticate with a GitHub personal access token
You can also open the Git Changes window to push and pull.
📁 How to Push a Local Repo to GitHub
You already have a local repo and want to push to GitHub?
git remote add origin https://github.com/user/repo.git git push -u origin main
🧮 How to Push Jupyter Notebook to GitHub
To upload a .ipynb notebook:
- Navigate to the folder
- Run Git commands:
git add your_notebook.ipynb git commit -m "Add notebook" git push
Your notebook will render beautifully in GitHub’s UI.
📈 How to Push with Large Files
If your file is over 100MB, GitHub blocks the push. Use Git LFS:
git lfs install git lfs track "*.psd" git add .gitattributes git add largefile.psd git commit -m "Add large file" git push
❓ Troubleshooting Git Push Issues
- Authentication failed? Use a GitHub personal access token
- Push rejected? You may need to git pull before pushing
- Wrong branch? Use git checkout main or the correct branch
- Want to undo push?
git revert <commit_hash>
Or use:
git push --force
⚠️ Warning: Force pushing rewrites history — use with caution.
💬 FAQs: How to Push to GitHub
How do I push to GitHub from terminal?
Initialize repo → Add remote → Add files → Commit → Push.
How do I push to a new branch on GitHub?
Use git checkout -b branch-name and git push -u origin branch-name.
Can I push code from VSCode to GitHub?
Yes, use the Source Control panel or Git terminal in VSCode.
How do I push updates to GitHub?
Use git add, git commit, then git push to update the repo.
How do I push an existing project to GitHub?
Initialize Git in the folder and connect it to your GitHub repo.
Push code with confidence — and let Everhour’s time tracker handle the rest, from time tracking to reporting via its GitHub time tracking integration. Track every commit’s time impact, generate reports, and keep projects running smoothly — automatically.
Learn more about GitHub from our articles:
- How to enable GitHub dark mode
- What is GitHub personal access token and how to set it up
- How to work with GitHub project management
- How to host a website on GitHub
- What are GitHub templates
- How GitHub Copilot vs ChatGPT work