Version control is a system that records changes to files over time, so you can easily track and manage different versions of your project. Imagine you're working on a long-term coding project or writing a big essay, and you want to test new ideas without messing up your current work. With version control, you can:
- Revert to previous versions of your files if something goes wrong.
- Collaborate with others on the same project without overwriting each other's work.
- Track your progress and see exactly what has changed over time.
Git is the most popular version control system used today, and GitHub is a platform that hosts Git repositories (repos), allowing you to store and share your code or projects online.
GitHub is a cloud-based platform for managing Git repositories, making it easier to:
- Collaborate: Work with others on a project, no matter where they are.
- Share: Publish your projects, get feedback, and show your work to the world (like potential employers).
- Manage versions: Keep track of all the changes you and your team make to a project.
- Open source: Contribute to other people's public projects or allow others to contribute to yours.
- A repository is a project folder on GitHub where all your files live. It also stores the history of every change made to those files.
- You can create different repositories for different projects, and they can be either public (everyone can see them) or private (only you or people you invite can see them).
- A commit is like a checkpoint. Every time you make significant changes to your project, you create a commit with a message explaining what you changed.
- Think of it as saving a version of your project.
- A branch is like a parallel universe for your project. You can make a new branch to try out new features or ideas without affecting the main project (called the
mainormasterbranch). - Once your work in the branch is ready, you can merge it back into the main project.
- When you finish making changes in your branch, you can submit a pull request (PR). This is a request to merge your changes into the main project.
- PRs are reviewed by others (or yourself) before they are merged to ensure everything works correctly.
- Start by creating a repository on GitHub by clicking the green "New" button on your dashboard.
- Name your repo something relevant, like
My_First_ApporHistory_Essay.
- You can clone (download) the repo to your computer and work on your files using your favorite editor (like VSCode, Sublime, etc.).
- When you make changes, you can track them using Git commands (more on that below).
- After making changes to your project, you’ll commit those changes with a meaningful message (e.g., "Fixed login bug" or "Added introduction to essay").
- Then, you push those changes to GitHub to keep your online repo up to date.