Git and GitHub
This section provides an introduction to version control using Git and collaborative development with GitHub. It covers the basics of Git, including how to create repositories, commit changes, and manage branches. Additionally, it explores how to use GitHub for hosting repositories, collaborating with others, and contributing to open-source projects.
What is Git and Github?
What is Git?
Git is a distributed version control system (DVCS). Unlike older systems (like Subversion or CVS) that rely on a central server, Git allows every developer to keep a full copy of the repository, including its history, on their local machine.
Key features:
- Version Tracking - Every change is saved as a commit, with a timestamp, author, and message.
- Branching & Merging – Developers can create branches for experiments, bug fixes, or features, then merge them back into the main project.
- Local-first – Work offline and sync changes later.
- Safety – Commits are checksummed with SHA-1 hashes, making it nearly impossible to corrupt or lose history without detection.
Example workflow in Git (Local-first):
git init # Start a new repo
git add file.txt # Stage changes
git commit -m "Message" # Commit snapshot
git branch feature-login # Create a new branch
git checkout feature-login # Switch to branch
What is GitHub?
GitHub is a cloud-based hosting platform for Git repositories. It adds collaboration, social, and automation layers on top of Git:
- Hosting – Push your local repo to GitHub to share with others.
- Collaboration – Teams can work on the same code using forks, pull requests, and code reviews.
- Issue Tracking – Report bugs, request features, or assign tasks.
- Actions (CI/CD) – Automate testing and deployment when new code is pushed.
- Community & Networking – Developers showcase work and connect with peers.
Github vs Git:
- Git is the tool for version control; GitHub is a service that hosts Git repositories.
- Git can be used locally without GitHub, but GitHub requires Git to function.
- Git focuses on code management; GitHub adds collaboration and social features.
- Git is command-line based; GitHub provides a web interface.