Git Setup

Summary

This note explains a practical first-time Git setup: install Git, configure identity, generate an SSH key, connect GitHub, and push the first repository. It is written as a general Git workflow, not a distro-specific setup note.

Why this matters

  • Git is a core tool for projects, documentation, automation, and version control
  • a clean initial setup avoids repetitive configuration mistakes later
  • SSH authentication gives a cleaner long-term GitHub workflow than ad-hoc login prompts

Environment / Scope

ItemValue
Main toolsgit, ssh-keygen, ssh-agent
Best use for this notefirst-time Git and GitHub setup
Platformgeneral workflow
Safe to test?yes, in a lab

Key concepts

  • Git identity - your name and email in commit metadata
  • SSH key authentication - a clean way to authenticate with GitHub
  • Remote repository - the hosted repository you connect your local repo to
  • First push - the first clean verification that local Git and remote GitHub work together

Steps / Workflow

1. Verify Git is installed

git --version

2. Configure Git identity

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main

3. Create an SSH key

ssh-keygen -t ed25519 -C "you@example.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

4. Copy the public key and add it to GitHub

cat ~/.ssh/id_ed25519.pub

Then in GitHub:

  1. open Settings
  2. open SSH and GPG keys
  3. choose New SSH key
  4. paste the public key
  5. save

5. Test GitHub SSH

ssh -T git@github.com

Expected first-time behaviour:

  • you may need to trust the host key
  • after that, GitHub should confirm the authentication worked

6. Create a repo and push the first commit

mkdir myrepo
cd myrepo
git init
echo "# myrepo" > README.md
git add .
git commit -m "Initial commit"
git remote add origin git@github.com:YOURUSER/myrepo.git
git push -u origin main

Commands / Examples

CommandPurpose
git config --global --listshow current global Git config
git remote -vshow remotes
git statuscheck working tree state
ssh -T git@github.comtest GitHub SSH authentication

Verification

CheckExpected result
Git existsgit --version works
Git identity existsgit config --global --list shows expected values
SSH auth worksssh -T git@github.com succeeds
Remote worksfirst push completes successfully

Verification commands:

git --version
git config --global --list
git remote -v
git status
ssh -T git@github.com

Pitfalls / Troubleshooting

ProblemLikely causeWhat to check
Git is missingnot installed or wrong pathgit --version
SSH auth failskey not added or agent not using itssh-add, public key in GitHub
Push failswrong remote URL or auth problemgit remote -v, SSH test
Wrong author info in commitsidentity not configuredgit config --global --list

Common beginner trap

Many Git problems later are really setup problems from the beginning. It is worth verifying identity, SSH, and remote configuration before assuming Git itself is broken.

Key takeaways

  • a clean Git setup is mostly identity, SSH, and remote verification
  • testing each step early makes later work much smoother
  • GitHub SSH is worth setting up properly instead of leaving it half-configured

Official documentation