Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

🚀 GitHub Guide: Beginner to Pro

Welcome to your journey from GitHub beginner to pro. This repository is a practical guide to Git + GitHub workflows, collaboration, automation, and common troubleshooting—so you can confidently handle real-world GitHub projects.


Table of Contents


About

This repository is a hands-on guide to mastering GitHub—from creating your first repository to leveraging automation, collaboration, and security features.

If you’re ever stuck with Git/GitHub errors (authentication, push/pull issues, upstream setup, SSH problems, verified commits), check the Troubleshooting section below.


Features

Feature Description Status
Commit & Push Save and upload code to GitHub ✅
Branching & Merging Develop features safely with branches ✅
Issues & Pull Requests Track tasks and propose code changes ✅
Workflows & CI/CD Automate testing and deployment ✅
GitHub Pages Host project documentation or websites ✅
Security & Dependabot Automated vulnerability alerts ✅
Project Boards Organize and plan project tasks ✅
Wiki Collaborative project documentation ✅
Actions Marketplace Use ready-made automation actions ✅

Getting Started

1) Clone Your Repository

git clone https://github.com/your-username/your-repo.git
cd your-repo

2) Add a File and Commit

echo "# Hello, GitHub!" > hello.md
git add hello.md
git commit -m "Add hello.md"
git push

3) Create a Branch

git checkout -b feature/my-feature

4) Open a Pull Request

  1. Push your branch:
    git push -u origin feature/my-feature
  2. Go to your repo on GitHub, click "Compare & pull request".

Git Basics (Global Username & Email)

These settings decide who Git says you are in commits (author name/email).

Set global username and email

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

Check your current global config

git config --global --get user.name
git config --global --get user.email
# or list everything:
git config --global --list

Set username/email for only ONE repository (local)

Run inside the repo folder (no --global):

git config user.name "Your Name"
git config user.email "you@example.com"

Login to GitHub using Git (Authentication)

Git itself doesn’t have a login command. To “login” for Git operations (clone/push/pull), you authenticate using one of the methods below.

Method 1 — HTTPS + Personal Access Token (PAT)

When you push/pull over HTTPS, GitHub requires a token (PAT), not your account password.

  1. Check remote:
git remote -v
# https://github.com/<user>/<repo>.git
  1. Do a Git operation:
git pull
# or
git push
  1. Enter:
  • Username: your GitHub username
  • Password: a GitHub Personal Access Token (PAT)

Optional (Linux): cache credentials:

git config --global credential.helper store

Method 2 — SSH (recommended)

SSH avoids repeated token prompts and is the standard for dev workflows.

  1. Generate a key (ED25519 recommended):
ssh-keygen -t ed25519 -C "you@example.com"
  1. Add key to ssh-agent:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
  1. Add public key to GitHub:
cat ~/.ssh/id_ed25519.pub

GitHub → Settings → SSH and GPG keys → New SSH key

  1. Test login:
ssh -T git@github.com
  1. Switch your repo remote to SSH:
git remote set-url origin git@github.com:<user>/<repo>.git

Method 3 — GitHub CLI (gh auth login) (easy interactive)

gh auth login
gh auth status

Working with GitHub

  • Issues: Report bugs, request features, and discuss ideas.
  • Pull Requests: Propose changes and get feedback.
  • Fork & Star: Copy repositories and bookmark your favorites.
  • Watch: Get notified about project activity.
  • Labels & Milestones: Organize issues and PRs.

Authentication: HTTPS, SSH, and Verified Commits (GPG)

Option A — HTTPS (easy start)

When Git asks for a password, use a Personal Access Token (PAT) instead of your GitHub password.

Helpful checks:

git remote -v
git config --global credential.helper

Option B — SSH (recommended)

You can follow a step-by-step SSH + GPG guide here:

Typical SSH flow:

ssh-keygen -t ed25519 -C "you@example.com"
ssh -T git@github.com

Verified commits (GPG signing)

If you want the “Verified” badge on GitHub commits, configure commit signing.

Common config:

git config --global commit.gpgsign true
git config --global user.signingkey <YOUR_KEY_ID>

Common Git & GitHub Errors (Fix Guide)

1) fatal: Authentication failed

Cause: Wrong credentials, password used instead of token, or expired token.
Fix: Use a PAT for HTTPS, or switch to SSH.

Quick check:

git remote -v

2) Permission denied (publickey)

Cause: SSH key not added, wrong key used, or not uploaded to GitHub.
Fix:

ssh -T git@github.com
ssh-add -l

If needed:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

3) fatal: repository '...' not found

Cause: Wrong URL, repo renamed, no access, or wrong remote.
Fix:

git remote -v
git remote set-url origin <correct-url>

4) error: failed to push some refs

A. Remote has new commits

git pull --rebase origin main
git push

B. Upstream not set

git push -u origin <branch-name>

5) fatal: The current branch ... has no upstream branch

Fix:

git push -u origin <branch-name>

6) You have divergent branches and need to specify how to reconcile them

Recommended:

git pull --rebase

Optional: set default behavior:

git config --global pull.rebase true
# or:
git config --global pull.ff only

7) Undo mistakes (quick commands)

Undo last commit but keep changes staged:

git reset --soft HEAD~1

Undo last commit and unstage changes:

git reset HEAD~1

Discard local changes (danger):

git reset --hard

Recover lost commits:

git reflog

Advanced Features

GitHub Actions (CI/CD)

Automate workflows like testing, building, or deploying.

# .github/workflows/ci.yml
name: CI
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Set up Node.js
      uses: actions/setup-node@v4
      with:
        node-version: '18'
    - name: Install dependencies
      run: npm ci
    - name: Run tests
      run: npm test

Security & Dependabot

  • Enable Dependabot for automatic dependency updates.
  • Add a .github/CODEOWNERS file for required reviews.
  • Use branch protection rules.
  • Never commit secrets (use GitHub Secrets for Actions).

GitHub Pages

Host static websites or documentation directly from your repository.

Project Boards

Use GitHub Projects to visualize and manage work.


Best Practices

  • Use clear commit messages (git commit -m "Add user authentication")
  • Add a CONTRIBUTING.md if you want external contributions
  • Protect your default branch and require PR reviews
  • Use .gitignore to avoid committing junk files
  • Do not commit secrets (tokens, private keys, .env files)

Resources


License

This project is licensed under the Apache License 2.0. See LICENSE for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors