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
| Item | Value |
|---|---|
| Main tools | git, ssh-keygen, ssh-agent |
| Best use for this note | first-time Git and GitHub setup |
| Platform | general 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 --version2. Configure Git identity
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main3. Create an SSH key
ssh-keygen -t ed25519 -C "you@example.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed255194. Copy the public key and add it to GitHub
cat ~/.ssh/id_ed25519.pubThen in GitHub:
- open
Settings - open
SSH and GPG keys - choose
New SSH key - paste the public key
- save
5. Test GitHub SSH
ssh -T git@github.comExpected 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 mainCommands / Examples
| Command | Purpose |
|---|---|
git config --global --list | show current global Git config |
git remote -v | show remotes |
git status | check working tree state |
ssh -T git@github.com | test GitHub SSH authentication |
Verification
| Check | Expected result |
|---|---|
| Git exists | git --version works |
| Git identity exists | git config --global --list shows expected values |
| SSH auth works | ssh -T git@github.com succeeds |
| Remote works | first push completes successfully |
Verification commands:
git --version
git config --global --list
git remote -v
git status
ssh -T git@github.comPitfalls / Troubleshooting
| Problem | Likely cause | What to check |
|---|---|---|
| Git is missing | not installed or wrong path | git --version |
| SSH auth fails | key not added or agent not using it | ssh-add, public key in GitHub |
| Push fails | wrong remote URL or auth problem | git remote -v, SSH test |
| Wrong author info in commits | identity not configured | git 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