How to get started with GitHub

Author

Javier Carpinteyro Ponce

Published

May 9, 2025

This is a tutorial on how to create a local GitHub repository, and how to push it to GitHub.com

Step 1: Create a directory for your local repository and git init

mkdir my-project
cd my-project
git init

Step 2: Add your first files and commit

echo "# My Project" > README.md  # or add your actual files
git add .
git commit -m "Initial commit"

Step 3: Create a new repository on github.com

Go to https://github.com/new and:

  • Enter a repository name (e.g., my-project)

  • Choose Public or Private

  • Click Create repository

👉 Don’t initialize it with a README, .gitignore, or license (you already did locally).

Step 4: Add the remote and push

git remote add origin git@github.com:username/my-project.git
git push -u origin main

If you need to set up your ssh key, you might need to do the following first:

Optional

  • Check for existing SSH keys

    ls -al ~/.ssh
  • Generate a new SSH key if needed

    ssh-keygen -t ed25519 -C "your_email@example.com"
    
    # Use your GitHub email address. If your system doesn't support ed25519, fall back to:
    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    • Press Enter to accept the default file location (~/.ssh/id_ed25519)

    • Set a passphrase (optional but recommended)

  • Start the SSH agent and add your key

    # Start the agent
    eval "$(ssh-agent -s)"
    
    # Add your SSH private key
    ssh-add ~/.ssh/id_ed25519
  • Copy your SSH public key

    cat ~/.ssh/id_ed25519.pub
  • Add the SSH key to GitHub

  • Test the connection

    ssh -T git@github.com

How How to switch from HTTPS remote URL to SSH

  • Step 1: Check your current remote URL

    git remote -v
    • you should see something like:

      origin  https://github.com/username/repo.git (fetch)
      origin  https://github.com/username/repo.git (push)
  • Step 2: Switch to SSH

    git remote set-url origin git@github.com:username/repo.git