Version control is a system that records changes to a file or set of files over time, enabling you to recall specific versions later. Git is one of the most popular distributed version control systems. GitHub is a web-based platform that provides hosting for software development and a range of tools for collaboration.
-
Repository (Repo): A Git repository is a collection of files and their revision history. Repositories can be local or remote.
-
Commit: A commit is a snapshot of the repository at a specific point in time. It records changes to one or more files.
-
Branch: A branch is an independent line of development. Changes made in one branch do not affect other branches until they are merged.
-
Merge: Merging combines changes from one branch into another. It's used to integrate code.
-
Pull Request (PR): A pull request is a mechanism for a developer to notify team members that they've completed a feature or fixed a bug.
-
Setting Up Git:
- Install Git on your local machine.
- Configure Git with your name and email.
git config --global user.name "Your Name" git config --global user.email "your.email@example.com"
-
Creating a Repository:
- Create a new local Git repository.
git init my-project
-
Adding and Committing:
- Add files to the staging area and commit changes.
git add . git commit -m "Initial commit"
-
Branching:
- Create a new branch.
git checkout -b new-feature
-
Pushing to GitHub:
- Push your local repository to GitHub.
git remote add origin https://github.com/yourusername/my-project.git git branch -M main git push -u origin main
-
Pull Requests:
- Create a new branch, make changes, and push it to GitHub.
- Create a pull request for your changes to be reviewed and merged.
-
Merging and Pulling:
- Review a pull request and merge it into the main branch.
-
Collaboration: Multiple developers can work on the same project simultaneously.
-
History and Tracking: Every change is tracked, providing a detailed history of the project.
-
Backup: Repositories are stored both locally and remotely, ensuring that your code is safe.
-
Experimentation: Developers can create branches for experimentation without affecting the main codebase.
-
Code Review: Pull requests enable peer review, improving code quality.
In the context of the course, students will learn how to use Git and GitHub to manage their codebase efficiently. They'll understand branching strategies, collaboration workflows, and best practices for version control. These skills are fundamental for any developer and are highly sought after in the industry.