Magazine / How to push your project to GitHub, step by step

How to push your project to GitHub, step by step

6 min read

Your project works, but the code only lives on your computer? Then it’s time for GitHub. This guide shows you three ways to push your project to GitHub: with the mouse, in the terminal or with AI. Plus the common error messages and how to fix them.

  1. Your folderThe code sits on your computer.
  2. CommitGit saves a version with a short note.
  3. PushThe new versions go online.
  4. GitHubYour repository lives there, safe and with history.
Pushing means uploading the versions Git saved on your computer to GitHub.

What does “push” mean?

Git is a program on your computer that saves versions of your code. Each saved version is called a commit. GitHub is a website where these versions live online. Pushing means uploading the commits from your computer to GitHub.

That gives you three things:

  • Backup: if your laptop breaks, your code isn’t gone.
  • History: you can restore any earlier version when something breaks.
  • Deployment: hosts like Vercel, Netlify or Coolify fetch your code straight from GitHub and put it online again with every push.

Before you start: what must not be uploaded

Before your first push, create a file called .gitignore in your project folder. Git leaves out everything listed there. For a typical web project this is enough. .env* covers every file with keys, such as .env.local or .env.production; only the template .env.example without real values may go along:

node_modules/
.env*
!.env.example
.DS_Store
dist/

Passwords and API keys never belong on GitHub. They usually sit in the .env file, which is why it’s on the list above. GitHub does block many well-known keys automatically in public repositories (push protection), but you shouldn’t rely on it. Also, a .gitignore only works for files that have never been committed. So before your first commit, check with git status which files are included.

One more privacy tip: every commit contains a name and an email address. If you don’t want to show yours, use GitHub’s anonymous address. You’ll find it under Settings, Emails, “Keep my email address private”.

Option 1: GitHub Desktop, no terminal

The easiest way if you’ve never worked with Git before.

  1. Download GitHub Desktop and sign in with your GitHub account.
  2. Choose File, Add local repository and pick your project folder. If it isn’t a Git repository yet, the app offers to create one.
  3. You’ll see all files on the left. Write a short note like “First version” at the bottom and click Commit to main.
  4. Click Publish repository at the top. Keep “Keep this code private” ticked if your code shouldn’t be public.

Done. From now on, after every change: write a note, commit, then “Push origin”.

Option 2: In the terminal with the GitHub CLI

The GitHub CLI (command gh) handles sign-in and setup in one go. On a Mac you install it with brew install gh. Then in the terminal:

gh auth login
cd my-project && git init -b main && git add . && git status

gh auth login opens the browser once to sign in. Replace my-project with the path to your project folder. The && makes sure nothing else runs if the folder doesn’t exist. git status then shows you every file that goes into the first commit. If nothing on the list should stay secret, carry on:

git commit -m "First version"
gh repo create my-project --private --source=. --push

The last command creates the repository on GitHub, connects it to your folder and uploads everything. Instead of --private you can use --public.

On your very first commit, Git may ask for your name and email address. Set them once with git config --global user.name "Your Name" and git config --global user.email "your address".

Option 3: Into an existing repository

If you’ve already created the repository on github.com, you connect your folder to it. GitHub shows you the address right after you create it. Best create the repository empty, without a README, otherwise your first push will run into a conflict. You need to be signed in as in option 2 with gh auth login. Then, in your project folder:

git init -b main
git add .
git status
git commit -m "First version"
git remote add origin https://github.com/YOUR-NAME/my-project.git && git push -u origin main

The first four commands create the local repository and the first commit. If your folder is already a Git repository with commits, start at git remote add. If git remote -v already shows an address for “origin”, the folder is already connected to another repository. Then git remote add stops, and the && makes sure nothing gets pushed either. If your branch has a different name there, such as “master”, use that name instead of “main” when you push. git branch shows which branch is active. The -u remembers the connection, so afterwards git push is enough.

With Claude Code or Codex

If you work with an AI assistant like Claude Code or Codex, you can simply write: “Upload my project to GitHub as a private repository.” The AI creates the .gitignore, makes the first commit and uses the GitHub CLI. You just need to have run gh auth login yourself once beforehand. Still, take a look at which files end up in the commit before it pushes.

After that: uploading changes

Day to day, you only need three commands after you’ve changed something:

git add .
git commit -m "Add pricing page"
git push

Better many small commits with a clear note than one big one now and then. That way you’ll quickly find the version where something broke.

PrivatePublic
Who can see the code?Only you and people you inviteEveryone
Good forSaaS, client projects, anything with business logicOpen source, learning projects, portfolio
Brings visitors?NoYes, through stars, search and lists

Common error messages

  • “Support for password authentication was removed”: since August 2021, GitHub no longer accepts a password when you push. Sign in with gh auth login or GitHub Desktop.
  • “Updates were rejected because the remote contains work”: there’s something on GitHub you don’t have, often a README. Fetch it first with git pull --rebase origin main, then push.
  • “src refspec main does not match any”: there’s no commit yet, or your branch has a different name, often “master”. Make a commit first. git branch shows which branch is active. Then push it by its name, for example git push -u origin master.
  • “Repository not found” even though it exists: you’re signed in with a different account that has no access. Check with gh auth status and switch with gh auth switch.

GitHub as marketing for your project

A public repository is more than storage. Developers search there for tools, and AI search reads GitHub too.

  • A good README: one sentence at the top saying what your project does, a screenshot and the link to your website.
  • Set topics: keywords on the right of your repository, so it shows up in GitHub search.
  • Get into lists: many “awesome” lists on GitHub accept new projects via pull request. That’s a suggested change to the list, which the owner accepts.
  • Link it on pushmyproject.com: if you add the repository link to your listing, we feature it on your product page.

More ideas for your first users are in our guide Marketing for your SaaS.

Conclusion

Pushing your project to GitHub takes ten minutes the first time. The easiest way is GitHub Desktop, the fastest is gh repo create --source=. --push. The only important thing is a .gitignore that keeps passwords and keys out. After that, three commands per change are enough, and your code is backed up, versioned and ready to deploy.

Your project is on GitHub? Show it!

List it on pushmyproject.com for free: your own product page with a backlink, a repository card and a score for Google and AI search.

Submit your project

FAQ

How do I upload my project to GitHub?

The easiest way is GitHub Desktop: add your folder, make a first commit and click “Publish repository”. In the terminal, use git init, git add, git commit and gh repo create --source=. --push.

Is my code public on GitHub?

Only if you want it to be. When you create the repository you choose private or public. A private repository can only be seen by you and the people you invite. You can change this later in the settings.

Why doesn’t GitHub accept my password?

Since August 2021, GitHub no longer accepts your account password when you push. Sign in with gh auth login or GitHub Desktop instead, and they handle authentication for you.

I accidentally pushed an API key. What now?

Replace the key with the provider right away. Deleting the file isn’t enough, because the old version stays visible in the repository history.

Sources