Creating a GitHub Account
A GitHub account is your identity on GitHub — the free, cloud-hosted service that stores Git repositories, powers pull requests and code review, runs automation through GitHub Actions, and hosts millions of open-source projects. You do not need a GitHub account to use Git itself: Git is a standalone tool that works entirely on your own machine, tracking history in a local .git folder. But the moment you want to back up a repository online, collaborate with other people, or contribute to someone else’s project, you need a GitHub account to authenticate against. This lesson walks through creating that account, verifying it, and connecting it to the Git installed on your computer so your commits and pushes are properly attributed and authenticated.
Overview / How it works
It helps to keep two separate identities straight, because beginners often conflate them. The first is your local Git identity: the user.name and user.email values stored in a plain text file, ~/.gitconfig, on your own computer. Git embeds these two strings into every commit object you create — they are baked into the commit’s metadata alongside the timestamp and the parent commit’s hash. This identity is never checked or verified by anything; you could type any name and email and Git would happily accept it. The second is your GitHub account: a server-side identity, protected by a password and (ideally) two-factor authentication, that lives on GitHub’s servers and controls what repositories you can read from and write to.
These two identities connect through your email address. When you push a commit to GitHub, GitHub reads the committer email embedded in that commit object and checks whether it matches one of the verified email addresses attached to any GitHub account. If it matches yours, GitHub links the commit to your profile: your avatar appears next to it, it counts toward your public contribution graph, and it shows up in your profile’s activity feed. If the email doesn’t match any verified GitHub email, the commit still pushes successfully — Git doesn’t require GitHub’s involvement to create a commit — but GitHub displays it as an anonymous commit with no linked profile.
Authentication (proving you’re allowed to push or pull) is a separate concern from attribution (whose name is on the commit). GitHub retired plain password authentication over HTTPS in August 2021, so you now authenticate one of two ways: with a Personal Access Token (PAT) used in place of a password over HTTPS, or with an SSH key pair, where a private key stays on your machine and a matching public key is registered with your GitHub account. Both are covered in the examples below. Repositories on GitHub are namespaced under your account or an organization — for example github.com/adalovelace/hello-world — and your username becomes a permanent part of every URL to your repos, issues, and pull requests, so it’s worth choosing thoughtfully at signup.
Syntax
Creating the account itself is a web form, not a command, so the “syntax” here is the sequence of steps plus the Git and GitHub CLI commands you run afterward to connect your machine to that account.
- Go to
github.com/joinand enter a username, email address, and password. - Verify you’re human (GitHub runs a short puzzle/verification step).
- Check your inbox for a verification email and click the confirmation link, or enter the launch code shown.
- Choose the free plan (sufficient for public and private personal repositories).
- Configure your local Git installation to use the same name and email, then set up authentication (SSH or a PAT).
| Command | Purpose |
|---|---|
git config --global user.name "<name>" |
Sets the name embedded in every commit you create on this machine. |
git config --global user.email "<email>" |
Sets the email embedded in every commit; should match a verified GitHub email to link commits to your profile. |
ssh-keygen -t ed25519 -C "<email>" |
Generates a new SSH key pair used to authenticate with GitHub without typing a password. |
ssh -T git@github.com |
Tests that your SSH key is correctly registered and GitHub accepts the connection. |
gh auth login |
Authenticates the GitHub CLI (and optionally Git itself) using a token-based browser or token flow. |
Examples
Example 1: Setting your local Git identity to match your GitHub account
After creating your account with the email ada@example.com, configure Git so every commit you make is attributed correctly.
git config --global user.name "Ada Lovelace"
git config --global user.email "ada@example.com"
git config --global --list
Output:
user.name=Ada Lovelace
user.email=ada@example.com
The --global flag writes these values to ~/.gitconfig, so they apply to every repository on this machine unless a specific repo overrides them with a local (non-global) git config call. The final --list command reads that file back so you can confirm the values were saved correctly before you make your first commit.
Example 2: Generating an SSH key and registering it with GitHub
SSH keys let you push and pull without entering credentials on every request. Generate a key pair, then copy the public half into GitHub.
ssh-keygen -t ed25519 -C "ada@example.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub
Output:
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/ada/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Your identification has been saved in /home/ada/.ssh/id_ed25519
Your public key has been saved in /home/ada/.ssh/id_ed25519.pub
Agent pid 4821
Identity added: /home/ada/.ssh/id_ed25519 (ada@example.com)
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... ada@example.com
ssh-keygen writes two files: a private key (id_ed25519) that must never leave your machine or be shared, and a public key (id_ed25519.pub) that is safe to hand out. ssh-agent and ssh-add load the private key into memory so you aren’t prompted for its passphrase on every push. The final cat command prints the public key so you can paste it into GitHub under Settings > SSH and GPG keys > New SSH key.
Example 3: Verifying the connection and using it to clone
Once the public key is registered on GitHub, confirm the connection works before relying on it.
ssh -T git@github.com
git clone git@github.com:adalovelace/hello-world.git
Output:
Hi adalovelace! You've successfully authenticated, but GitHub does not provide shell access.
Cloning into 'hello-world'...
remote: Enumerating objects: 12, done.
remote: Total 12 (delta 0), reused 0 (delta 0), pack-reused 12
Receiving objects: 100% (12/12), done.
The greeting from ssh -T confirms GitHub matched your private key to a public key on file for the account adalovelace — the “does not provide shell access” message is expected and simply means SSH auth succeeded but GitHub isn’t a general-purpose server. The subsequent clone then works without any password or token prompt.
Example 4: Authenticating with the GitHub CLI and a token instead
If you’d rather use HTTPS remotes, the gh CLI can handle token-based login for you.
gh auth login
gh auth status
Output:
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? How would you like to authenticate? Login with a web browser
! First copy your one-time code: 4A3B-9C2D
Press Enter to open github.com in your browser...
✓ Authenticated as adalovelace (https)
✓ Git operations for github.com configured to use https protocol.
✓ Logged in as adalovelace
gh auth login walks you through browser-based authentication and, once approved, stores a token securely in your system’s credential store, which Git then reuses automatically for HTTPS pushes and pulls — no manual token pasting required.
How it works step by step
Signing up creates a new row in GitHub’s user database keyed by your chosen username, and queues a verification email containing a one-time code or link; your account is fully active only after that step completes. Nothing about this process touches your local machine. Running git config --global simply writes two lines of text into ~/.gitconfig — it does not contact GitHub’s servers at all, which is why Git will let you set a name and email that don’t match any real account.
The SSH path works like this: ssh-keygen creates a mathematically linked key pair locally. You upload only the public key to GitHub, which stores it against your account. When you later run git push over an SSH remote, your SSH client presents a cryptographic challenge that only the holder of the matching private key can answer correctly — GitHub never sees or needs your private key, only proof that you possess it. The HTTPS/PAT path is simpler conceptually: the token itself acts as a bearer credential, sent over an encrypted HTTPS connection and checked against GitHub’s stored token for your account, along with whatever scopes (permissions) you granted the token when you created it. In both cases, once authentication succeeds, GitHub performs a second check — authorization — verifying that the authenticated account actually has write access to the specific repository being pushed to, whether as owner, collaborator, or organization member.
Common Mistakes
Mistake 1: Trying to push over HTTPS with a plaintext password. GitHub removed password authentication in August 2021, so this now fails outright.
git push https://github.com/adalovelace/hello-world.git main
Output:
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/adalovelace/hello-world.git/'
Fix: generate a Personal Access Token under Settings > Developer settings > Personal access tokens and use it in place of the password, or switch the remote to SSH with git remote set-url origin git@github.com:adalovelace/hello-world.git and use an SSH key instead.
Mistake 2: A local Git email that doesn’t match any verified GitHub email. Commits will push and appear in git log normally, but GitHub shows them as unlinked, with no avatar and no credit on your contribution graph. Check what your local config is set to and compare it against the emails listed under Settings > Emails on GitHub:
git config --global user.email
Mistake 3: Pasting the private key instead of the public key into GitHub. GitHub’s “New SSH key” field expects the contents of the .pub file. Pasting the private key (the file without the .pub extension) doesn’t work as a public key and, more importantly, would expose a secret that should never leave your machine if pasted anywhere else. Always double-check you’re copying id_ed25519.pub, not id_ed25519.
Best Practices
- Use an email address you control long-term (not a work address tied to a specific employer) so you don’t lose account access later.
- Make sure your local
git config user.emailmatches a verified email on your GitHub account, or your commits won’t be linked to your profile. - Enable two-factor authentication (an authenticator app is stronger than SMS) — GitHub accounts are a common target because they often hold access to private code and deploy credentials.
- Prefer SSH keys or a Personal Access Token stored in a credential manager over typing credentials manually every time.
- Give PATs the minimum scopes they need and set an expiration date; rotate and revoke ones you no longer use.
- Choose your username carefully — it becomes part of every repository, issue, and pull request URL you create.
- Set your Git identity with
--globalonce, right after installing Git, so you don’t forget before your first commit.
Practice Exercises
- Sign up at
github.com/join, verify your email, then rungit config --global user.nameandgit config --global user.emailto set your local identity so it matches a verified email on your new account. - Generate a new
ed25519SSH key withssh-keygen, add the public key to your account under Settings > SSH and GPG keys, and confirm it works by runningssh -T git@github.com— you should see a personalized greeting with your username. - Create a Personal Access Token with only the
reposcope and a 7-day expiration, use it once to clone a private repository over HTTPS, then find it under Settings > Developer settings > Personal access tokens and revoke it manually.
Summary
- A GitHub account is a separate, server-side identity from your local Git
user.name/user.emailconfig — the two connect through a matching, verified email address. - Local Git identity is never verified by Git itself; only GitHub checks it against your account when deciding whether to link a pushed commit to your profile.
- GitHub no longer accepts password authentication over HTTPS — use SSH keys or a Personal Access Token instead.
- SSH authentication relies on a private key that never leaves your machine and a public key registered with GitHub; test it with
ssh -T git@github.com. - The
ghCLI can automate token-based login for HTTPS remotes viagh auth login. - Enable two-factor authentication and scope any tokens narrowly, since a compromised GitHub account can expose every private repository you own.
