DevOps & Linux Administration
Git & GitHub Basics
Module VI: Git & GitHub Basics. This module introduces version control systems, Git fundamentals, GitHub workflows, repositories, commits, branches, and collaboration techniques used in modern software development and DevOps environments.
What is Version Control?
Version control is a system used to track changes made to files and source code over time. It allows developers to maintain project history, collaborate with teams, and restore previous versions whenever required.
Modern software development heavily relies on version control systems for teamwork and project management.
Version Control Workflow
What is Git?
Git is a distributed version control system developed by Linus Torvalds. It helps developers manage source code, track changes, and collaborate efficiently on projects.
Git stores snapshots of project files and maintains a complete history of changes made during development.
Fast
Git operations are highly optimized and efficient.
Distributed
Every developer has a complete copy of repository history.
Reliable
Git safely tracks and manages code changes.
What is GitHub?
GitHub is a cloud-based platform used to host Git repositories online. It enables developers to collaborate, share code, review contributions, and manage projects efficiently.
GitHub is widely used in open-source projects, software companies, and DevOps workflows.
GitHub Collaboration Flow
Repositories
A repository (repo) is a storage location for project files and Git history. It contains source code, documentation, configuration files, and commit history.
| Repository Type | Description |
|---|---|
| Local Repository | Stored on user's computer |
| Remote Repository | Hosted online on GitHub or cloud platforms |
Basic Git Commands
Git provides various commands to initialize repositories, track changes, and synchronize code.
| Command | Purpose |
|---|---|
| git init | Initializes a Git repository |
| git status | Shows repository status |
| git add | Adds files to staging area |
| git commit | Saves changes permanently |
| git push | Uploads changes to GitHub |
| git pull | Downloads latest changes |
Example Workflow
$ git init $ git add . $ git commit -m "Initial Commit" $ git push origin main
Git Branching
Branches allow developers to work on different features independently without affecting the main project code.
Branching Workflow
$ git branch feature-login $ git checkout feature-login
Pull Requests
A pull request (PR) is a request to merge changes from one branch into another branch on GitHub.
Pull requests are commonly used in open-source projects and team-based software development for reviewing code before merging.
Code Review
Team members review submitted code changes.
Discussion
Developers discuss improvements and fixes.
Merge
Approved changes are merged into main branch.
Git vs GitHub
| Git | GitHub |
|---|---|
| Version control system | Cloud hosting platform |
| Works locally | Works online |
| Tracks code history | Enables collaboration |
Summary
In this chapter, we explored Git, GitHub, repositories, version control workflows, Git commands, branching, pull requests, and collaboration techniques. These concepts are essential for modern software development and DevOps practices.