SkillNavora
Git & GitHub Complete Guide › Lesson 2 of 8 · about 20 minutes
Lesson 2

Set up Git and GitHub: install, identity, SSH keys, GitHub CLI and your first repository

Install Git on Windows, macOS or Linux, set your name and email, create a GitHub account with two-factor authentication, connect with SSH or the GitHub CLI, and create and clone your first repository.

Checked against official sources in November 2026. Lessons build on each other.
In plain words. Setting up Git is like getting a new bank account: install the app, tell it who you are, prove your identity to the bank (GitHub) with a secure key, then open your first account (repository).

Key ideas

git configSaves settings such as your name and email, for one repository or globally.
SSH keyA key pair on your computer that proves to GitHub it is you, without typing a password.
Personal access tokenA password-like token for HTTPS; use fine-grained tokens with an expiry date.
GitHub CLI (gh)GitHub's official command-line tool: sign in, create repositories and pull requests from the terminal.
Two-factor authentication (2FA)A second check (app, passkey or security key) when you sign in. Required for code contributors on GitHub.

How it works

1. Install Git

SystemHow
WindowsDownload Git for Windows from git-scm.com and keep the defaults (it includes Git Bash and Git Credential Manager). Or run winget install --id Git.Git -e.
macOSRun git --version; macOS offers to install the Command Line Tools. Or brew install git.
Linuxsudo apt install git (Ubuntu/Debian) or sudo dnf install git (Fedora).

Check it worked:

Real terminal output (captured when this guide was built)
$ git --version
git version 2.43.0

2. Tell Git who you are

One-time setup
git config --global user.name "Your Name"
git config --global user.email "[email protected]"     # use the email on your GitHub account
git config --global init.defaultBranch main
git config --global pull.rebase false                 # or true, if your team prefers rebasing
git config --list --show-origin                       # see every setting and where it came from
Tip. To keep your email private, use the no-reply address from GitHub Settings, Emails (it looks like [email protected]).

3. Create your GitHub account safely

  1. Sign up at github.com with a professional username (it appears in your portfolio links).
  2. Turn on two-factor authentication: Settings › Password and authentication. Use an authenticator app or a passkey, and save the recovery codes.
  3. Add a profile photo, bio and a profile README (a repository named exactly like your username).

4. Connect with SSH (recommended)

Create and add an SSH key
ssh-keygen -t ed25519 -C "[email protected]"   # press Enter for the default file, add a passphrase
cat ~/.ssh/id_ed25519.pub                    # copy this PUBLIC key
# GitHub: Settings > SSH and GPG keys > New SSH key > paste > Add
ssh -T [email protected]                        # "Hi <username>! You've successfully authenticated"

Never share the private key (the file without .pub). Use one key per computer, and delete keys for computers you no longer use.

5. Or use the GitHub CLI

Sign in and create a repository from the terminal
# install: winget install --id GitHub.cli   |   brew install gh   |   see cli.github.com for Linux
gh auth login                 # choose GitHub.com, HTTPS or SSH, and log in with your browser
gh repo create study-notes --public --clone --add-readme
cd study-notes && git log --oneline

6. Your first repository from scratch

Here is a real first session: create a folder, start Git, and see what status reports.

Real terminal output (captured when this guide was built)
$ git init
Initialized empty Git repository in /home/asha/notes/.git/
$ git config user.name "Asha Learner"
$ git config user.email "[email protected]"
$ echo '# My study notes' > README.md
$ git status
On branch main

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	README.md

nothing added to commit but untracked files present (use "git add" to track)
Stage and commit (real output)
$ git add README.md
$ git status --short
A  README.md
$ git commit -m "Add README with the course title"
[main (root-commit) 5e9b349] Add README with the course title
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
$ git log --oneline
5e9b349 Add README with the course title

To put it on GitHub, create an empty repository on github.com (no README), then follow Lesson 5 to add the remote and push.

Common mistakes and fixes

MistakeFix
Commits show the wrong name or emailSet user.name and user.email globally, and fix a single repository with git config (without --global).
Typing your GitHub password in the terminalGitHub does not accept account passwords for Git; use SSH, the GitHub CLI, or a token via the credential manager.
Sharing the private SSH keyOnly the .pub file is shared. If a private key leaks, delete it on GitHub and create a new one.

Practice

  1. Install Git, set your name and email, and run git config --list --show-origin.
  2. Create an SSH key, add it to GitHub and run ssh -T [email protected].
  3. Create a public repository called study-notes with gh or the website and clone it.

Quick check

Which command sets your name for every repository?

git config --global user.name "Your Name"

Which part of an SSH key do you paste into GitHub?

The public key (the .pub file).

Why turn on 2FA?

It protects your account and code; GitHub requires it for code contributors.

Go further (official sources)

Refer & earn