Skip to content

Latest commit

Β 

History

History
133 lines (95 loc) Β· 5.04 KB

File metadata and controls

133 lines (95 loc) Β· 5.04 KB

11 Β· GitHub Essentials

🏠 Handbook Home Β Β·Β  ⬅️ Prev: Command Reference Β Β·Β  Next: Pull Requests & Review ➑️


You now know Git (the tool). GitHub is the most popular place to host Git repositories and collaborate around them. This part of the handbook covers the GitHub-specific layer that sits on top of Git.

Remember the distinction from Chapter 1: Git runs on your machine; GitHub lives in the cloud. Everything here also has close equivalents on GitLab and Bitbucket.


Anatomy of a GitHub repository

When you open a repo on GitHub, you'll see these tabs:

Tab What it's for
Code The files, README, branches, and releases
Issues Bug reports, feature requests, to-dos
Pull requests Proposed changes under review (Chapter 12)
Actions Automated workflows / CI-CD (Chapter 14)
Projects Kanban boards & planning (Chapter 13)
Wiki Long-form documentation
Security Vulnerability alerts, policies
Insights Contributor stats & graphs
Settings Configuration (admins only)

The README.md is the front page β€” it renders automatically. A great README is the difference between a repo people star and one they scroll past. (You're reading a pretty good one right now. πŸ˜‰)


Creating & connecting a repo

On GitHub: click + β†’ New repository, give it a name, and create it.

Connect a local project to it:

git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin git@github.com:you/repo.git
git push -u origin main

Or start from GitHub by cloning the empty repo and working inside it.

⚑ The GitHub CLI (gh) does this in one step: gh repo create my-project --public --source=. --push.


Public vs. Private

Public Private
Who can see it Anyone Only you + invited collaborators
Good for Open source, portfolios Client work, secrets, WIP
Free? Yes Yes (with generous limits)

You can flip between them anytime in Settings β†’ General β†’ Danger Zone.


Forking 🍴

A fork is your own copy of someone else's repository, under your account. It's the foundation of open-source contribution: you can't push to a stranger's repo, but you can fork it, change your fork, and propose your changes back via a Pull Request.

The fork-and-PR flow:

# 1. Click "Fork" on GitHub β†’ you now have github.com/you/their-repo
# 2. Clone YOUR fork
git clone git@github.com:you/their-repo.git
cd their-repo
# 3. Add the ORIGINAL as 'upstream' so you can stay in sync
git remote add upstream git@github.com:original/their-repo.git
# 4. Create a branch, make changes, push to YOUR fork
git switch -c fix-typo
git commit -am "Fix typo in docs"
git push -u origin fix-typo
# 5. Open a Pull Request from your fork β†’ the original repo

Keep your fork up to date:

git fetch upstream
git switch main
git merge upstream/main      # or: git rebase upstream/main
git push                     # update your fork

The GitHub Flow πŸ”„

The simple, popular branching workflow GitHub itself recommends:

1. Branch     β†’ create a branch off main for your work
2. Commit     β†’ make changes in small commits
3. Push       β†’ publish your branch to GitHub
4. Pull Request β†’ open a PR to propose merging into main
5. Review     β†’ teammates review & discuss
6. Merge      β†’ merge into main (main is always deployable)
7. Delete     β†’ delete the branch

main is always kept in a working, shippable state. All work happens on short-lived branches that get reviewed before merging. More workflows in Chapter 15.


Your GitHub profile ⭐

A few touches that make your profile shine:

  • Profile README β€” create a repo named exactly your username (e.g. heyanzarkhan/heyanzarkhan) with a README.md; it shows on your profile page.
  • Pin your best repositories.
  • Achievements β€” badges like Pull Shark, Galaxy Brain, Starstruck, earned through activity.
  • Stars β€” bookmark repos you love; a repo's star count is its popularity signal.

βœ… Key takeaways

  • GitHub hosts Git repos and adds Issues, Pull Requests, Actions, and more.
  • Connect a local repo with git remote add origin … && git push -u origin main.
  • Fork to copy someone's repo to your account; sync with an upstream remote.
  • The GitHub Flow = branch β†’ commit β†’ push β†’ PR β†’ review β†’ merge β†’ delete.
  • A strong README and profile make your work discoverable.

🏠 Handbook Home Β Β·Β  ⬅️ Prev: Command Reference Β Β·Β  Next: 12 Β· Pull Requests & Review ➑️