To upload a local project to GitHub with Git and SSH, first make sure the folder is a Git repository with at least one commit, create an empty GitHub repository, configure and test SSH access, add the repository as a remote, then push your branch. The steps below cover a new project folder as well as the case where Git already tracks it.
1. Inspect the project before staging files
Open a terminal—or Git Bash on Windows—and move to the project’s root folder. Check what is there before you add files. GitHub warns: “Never git add, commit, or push sensitive information, for example passwords or API keys, to a remote repository.”
As an Amazon Associate I earn from qualifying purchases.
If the folder is already tracked by Git, do not initialize another repository. If it is not, initialize it and create an initial commit:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
cd /path/to/your-project
# Run this only if the folder is not already a Git repository:
git init -b main
git add .
git status
# Review the staged files and remove or unstage anything unintended.
git commit -m "First commit"
git init -b main is documented for Git 2.28.0 and later. If your Git version does not support that option, use the initialization method appropriate to your installed version. The status check helps you review the staged files, but it does not replace checking for secrets.
#1 Best Overall
- POWERFUL SECURITY KEY: The Security Key C NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
- WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key C NFC secures 100 of your favorite accounts, including email, password managers, and more.
- FAST & CONVENIENT LOGIN: Plug in your Security Key C NFC via USB-C and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
- TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
- BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.
2. Create an empty GitHub repository
On GitHub, create a new repository under the account or organization where the project should live. For this direct first-push workflow, leave the options to add a README, license, or gitignore file unchecked. That keeps the remote empty, avoiding a separate initial commit that may need to be reconciled with your local history.
Copy the SSH URL shown on the repository’s setup page. It has this form:
[email protected]:OWNER/REPOSITORY.git
Replace OWNER and REPOSITORY with the account or organization and repository names in the URL you copied.
3. Set up SSH authentication
Check for an existing key
Before generating a key, see whether you already have a suitable SSH key. GitHub’s documented check for the standard key directory is:
Rank #2
- POWERFUL SECURITY KEY: The YubiKey 5C NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
- WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5C NFC secures 100+ of your favorite accounts, including email, password managers, and more
- FAST & CONVENIENT LOGIN: Plug in your YubiKey 5C NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
- MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
- PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts
ls -al ~/.ssh
A public key commonly has a filename such as id_ed25519.pub. The matching private key has the same name without .pub; keep that private key on your computer and never paste it into GitHub.
Generate and load a key if needed
If you do not have a suitable key, GitHub’s standard Ed25519 example is:
ssh-keygen -t ed25519 -C "[email protected]"
Use the email associated with your GitHub account as the key’s label and choose a secure passphrase. Follow the prompts to save the key. On macOS or Linux, GitHub documents this agent setup pattern:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
Windows has separate SSH-agent instructions; follow the GitHub steps for your shell and setup rather than assuming the macOS/Linux commands apply unchanged.
Rank #3
- POWERFUL SECURITY KEY: The YubiKey 5 NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
- WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5 NFC secures 100+ of your favorite accounts, including email, password managers, and more
- FAST & CONVENIENT LOGIN: Plug in your YubiKey 5 NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
- MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
- PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts
Add the public key to your GitHub account
Copy the contents of the public-key file, the one ending in .pub. In GitHub, open Settings → SSH and GPG keys, choose to add a new SSH key, select Authentication as its purpose, and paste the public key. Do not paste or upload the private key.
4. Test the SSH connection
In a terminal, run:
ssh -T [email protected]
On the first connection, SSH may ask whether to trust GitHub’s host. Verify the displayed fingerprint against GitHub’s official fingerprint page before accepting. A successful test greets your GitHub username and says that GitHub does not provide shell access; that message is expected.
5. Add the remote and push your branch
From the project root, add the SSH URL you copied as the remote named origin, the conventional name for a primary remote. Then check that both displayed addresses point to the intended repository:
git remote add origin [email protected]:OWNER/REPOSITORY.git
git remote -v
If Git says origin already exists, inspect it with git remote -v. If it points to the wrong repository and you intend to change it, update the URL instead of adding another remote with that name:
Rank #4
- POWERFUL SECURITY KEY: The Security Key NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
- WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key NFC secures 100 of your favorite accounts, including email, password managers, and more.
- FAST & CONVENIENT LOGIN: Plug in your Security Key NFC via USB-A and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
- TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
- BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.
git remote set-url origin [email protected]:OWNER/REPOSITORY.git
Push the current branch and set its upstream tracking relationship:
git push -u origin main
Use your actual branch name in place of main. To see it, run git branch --show-current. When the push completes, open the repository page and confirm the expected files and commit appear.
When the first push does not follow the simple path
The folder is already a Git repository
Skip initialization and inspect its branch and remotes before pushing. Reusing an existing repository avoids creating a nested or unintended Git history.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →The branch is not called main
Use the name reported by git branch --show-current in the push command. The command’s branch argument must match the local branch you want to publish.
Best Value
- Security Key : Protect your online accounts against unauthorized access by using FIDO2 and U2F authentication with T110. It's the world's most protective security key that works with windows, Mac OS, Linux as well as Chrome, Firefox, Edge and many other major browsers.
- Certified with the new FIDO2 standard, T110 provides the benefit of fast login and strong protection against phishing, account takeover as well as many other online attactks.
- Works with : Bank of America, Github, Google, Microsoft, DUO, Twitter, Facebook, Dropbox, Apple, ebay, BINANCE, mor and more.
- Fits USB-A port : Insert the T110 security key into the USB-A port of each service and log in conveniently with one touch
- For the driver download and user guide, please visit TrustKey Solutions Home support page.
SSH reports “Permission denied (publickey)”
Check that the public key was added to the GitHub account that owns or can access the repository, and that the corresponding private key is available to your SSH agent. If you use multiple accounts or keys, make sure SSH is presenting the intended key.
The destination is an organization repository
An organization that enforces SAML single sign-on may require you to authorize your SSH key for that organization in addition to adding it to your GitHub account.
The GitHub repository already has a commit
The direct first-push steps assume an empty remote. If you initialized the GitHub repository with a README, license, or gitignore—or it already contains other commits—its history may differ from your local history. Reconcile the histories deliberately rather than assuming the simple push will work unchanged.
Free tools Windows power users keep installed
One-click scans. No signup required.
You committed a secret
Do not push credentials. Removing a sensitive file in a later commit does not remove it from earlier commits in the repository’s history. If a credential has been exposed, revoke or rotate it, then follow GitHub’s sensitive-data removal guidance to address the history.
Quick Recap
Official GitHub instructions
- Adding locally hosted code to GitHub
- About remote repositories
- About SSH
- Generating a new SSH key and adding it to the ssh-agent
- Adding a new SSH key to your GitHub account
- Testing your SSH connection
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




