Master Git & GitHub From Scratch

Clear, practical, and structured lessons designed to take you from Git fundamentals to real-world GitHub collaboration.

Forks vs. Clones

The core difference is that a fork creates a copy of a repository on your remote hosting account , such as GitHub, while a clone creates a copy of a repository on your local computer .

You use a fork when you want to contribute to someone else's project or use it as a starting point for your own project. You use a clone to download a repository to your computer so you can start writing code.


📘 Quick Comparison

Feature Fork Clone
What is it? A copy of a repository stored on a hosting platform. A local copy of a repository on your computer.
Where does it live? Your remote hosting account, such as GitHub. Your local hard drive, such as C:\projects\repo.
Permissions Permissions depend on the hosting platform and repository settings. Local editing is possible, but pushing depends on remote permissions.
Primary Use Contributing to open-source or shared projects through Pull Requests. Editing files, compiling code, testing, and daily development.
How to do it Click the Fork button on the repository website. Run git clone <repository-url> in your terminal.

🔄 How Fork and Clone Work Together

In a typical open-source workflow, you can use both a fork and a clone to contribute to an existing project.

1. Fork the Repository

Open the original project on GitHub and click Fork to create a copy under your own GitHub account.

2. Clone Your Fork

Download your fork to your computer so you can work with the project files.

git clone https://github.com/your-username/project.git
3. Make and Commit Changes

Open the project, create a feature branch, make your changes, and commit them.

git switch -c feature/my-change
git add .
git commit -m "Add my change"
4. Push Changes to Your Fork

Upload your feature branch to your remote fork.

git push -u origin feature/my-change
5. Open a Pull Request

On GitHub, open a Pull Request from your fork's feature branch to the original project's target branch. The maintainers can review your changes and decide whether to merge them.

Remember: Forking creates a remote copy. Cloning downloads a repository locally. Pushing uploads your commits, and a Pull Request proposes changes to another branch or repository.

💻 Useful Commands

Command Purpose
git clone <url> Download a remote repository to your computer.
git remote -v View configured remote repositories.
git switch -c feature/name Create and switch to a feature branch.
git push -u origin feature/name Push a feature branch and configure upstream tracking.
Key Takeaway: Fork a repository to create your own remote copy. Clone a repository to work on it locally. For many open-source contributions, you fork first, clone your fork, push your changes, and then open a Pull Request to the original project.