Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To upload a local project folder to GitHub with Git and SSH, first make sure the project has a Git commit, create an empty GitHub repository, authenticate with an SSH key, add the repository as a remote, and push your current branch. Review staged files carefully before committing: GitHub warns, “Never git add, commit, or push sensitive information, for example passwords or API keys, to a remote repository.”

Before you begin: check the project and its Git status

Open a terminal or Git Bash and move to the project’s root folder. Check what is already there before initializing anything:

cd /path/to/your-project
git status

If Git reports that the directory is not a repository, initialize it and create its first commit. GitHub documents git init -b main for Git 2.28.0 or later. If the folder is already tracked by Git, do not initialize a second repository; inspect its current branch and remotes instead.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
# Run only if this folder is not already a Git repository:
git init -b main

git add .
git status
# Review the staged files; unstage anything you do not intend to publish.
git commit -m "First commit"

Review the staged file list and check for credentials, private configuration, or other data you do not want public or shared. A later commit that deletes a secret does not erase it from the repository’s earlier history.

#1 Best Overall
Yubico - Security Key C NFC - Basic Compatibility - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified
  • 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.

Create an empty GitHub repository

On GitHub, create a new repository under the account or organization where the project belongs. For the simplest first push, leave the options to initialize it with a README, license, or gitignore file unchecked. That keeps the remote empty so its history does not start with a separate commit. Copy the SSH URL shown on the repository setup page.

An SSH remote commonly has this form:

git@github.com:OWNER/REPOSITORY.git

Replace OWNER and REPOSITORY with the correct account or organization and repository name. GitHub supports both SSH and HTTPS remotes; this procedure uses SSH.

Set up SSH authentication

Check for an existing key

Before creating a new key, inspect the standard SSH directory:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Yubico - YubiKey 5C NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified - Protect Your Online Accounts
  • 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

Look for a public key such as id_ed25519.pub and its corresponding private key. A public key is the file ending in .pub; never share or upload the private-key file.

Generate a key if you need one

If you do not have a suitable key, GitHub’s documented Ed25519 example is:

ssh-keygen -t ed25519 -C "your_email@example.com"

Use the email associated with your GitHub account as the key’s label and choose a secure passphrase when prompted. Keep the private key private. If you use Windows, follow GitHub’s Windows-specific instructions for the SSH agent; commands differ by shell and setup.

Rank #3
Yubico - YubiKey 5 NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-A or NFC, FIDO Certified - Protect Your Online Accounts
  • 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

Load the key and add its public half to GitHub

On macOS or Linux, GitHub documents this agent setup pattern:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

Then copy the contents of the public-key file and, in GitHub account settings, open SSH and GPG keys, choose to add a new SSH key, select Authentication as the key type, and paste the public key. Do not paste the private key. If the repository belongs to an organization that uses SAML single sign-on, the key may also need separate authorization for that organization.

Test the SSH connection

Run the connection test:

ssh -T git@github.com

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 the authenticated GitHub username and says that GitHub does not provide shell access; that is expected.

Rank #4
Yubico - Security Key NFC - Basic Compatibility - Multi-Factor Authentication (MFA) Key, Connect via USB-A or NFC, FIDO Certified
  • 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.

Add the remote and push your branch

Connect the local repository to GitHub

From the project root, add the SSH URL you copied. origin is the conventional name for the primary remote:

git remote add origin git@github.com:OWNER/REPOSITORY.git
git remote -v

Check that both the fetch and push URLs point to the intended repository. If Git says that origin already exists, inspect its URL with git remote -v. If it is the remote you intend to replace, update it instead of adding another remote with the same name:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
git remote set-url origin git@github.com:OWNER/REPOSITORY.git

Push the actual current branch

Find the current branch name, then use it in the push command:

Best Value
FIDO2 U2F Security Key Passkey Two-Factor Authentication (2FA) USB Key PIN+Touch (Non-Biometric) USB-A Type TrustKey T110
  • 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.
git branch --show-current
git push -u origin main

Replace main in the push command with the branch name reported by git branch --show-current if it differs. The -u option sets the upstream tracking relationship, so later pushes can use the configured remote and branch.

After Git reports a successful push, open the GitHub repository page and confirm that the expected files and commit appear.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

If the first push fails

The folder already has Git history or a remote

Skip initialization if the folder is already a Git repository. Inspect its branch with git branch --show-current and its remotes with git remote -v before changing anything. Keep an existing remote if it is already the intended repository; otherwise update its URL deliberately.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The GitHub repository already has a commit

The direct first-push steps assume the remote is empty. If you initialized the GitHub repository with a README, license, or gitignore, its history may differ from the local project’s history, and the push may not work as shown. Reconcile the histories carefully rather than treating the remote as empty.

SSH reports “Permission denied (publickey)”

Confirm that the public key was added to the GitHub account you are using and that the matching private key is available to your SSH agent. For an organization repository, check whether the key also needs SAML SSO authorization.

You discover a secret after committing

Do not push the commit. Removing a sensitive file in a later commit does not remove the earlier copy from repository history. If credentials have already been committed or pushed, follow GitHub’s sensitive-data removal guidance and rotate exposed credentials as appropriate.

Sources for the GitHub steps

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.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.