Introduction to Git
What is Version Control?
A version control system (VCS) is a program or set of programs that tracks changes to a collection of files. One goal of a VCS is to easily recall earlier versions of individual files or of the entire project. Another goal is to allow several team members to work on a project, even on the same files, at the same time without affecting each other's work.
Another name for a VCS is a software configuration management (SCM) system.
What is Git?
Git is distributed, which means that a project's complete history is stored both on the client and on the server. You can edit files without a network connection, check them in locally, and sync with the server when a connection becomes available. If a server goes down, you still have a local copy of the project. Technically, you don't even have to have a server. Changes could be passed around in e-mail or shared by using removable media, but no one uses Git this way in practice.
What are Git Terminology?
Before diving into Git commands, it’s important to get familiar with some basic terms you’ll hear often:
- Working Tree – The collection of files and directories you’re actively working on.
- Repository (Repo) – The top-level directory where Git stores all history and metadata of your project.
- Hash – A unique ID Git generates (using SHA-1) to track file changes.
- Object – Core building blocks in Git (blobs, trees, commits, tags), each identified by a hash.
- Commit – A snapshot of changes you’ve saved into Git’s history.
- Branch – A series of commits with a name (like main), used to work on features independently.
- Remote – A link to another repository, often called origin, used for pushing and pulling changes.
- Commands, Subcommands & Options – How you interact with Git (e.g., git push, git reset --hard).
What is the key difference between Git & GitHub?
It’s easy to mix up Git and GitHub, but they are not the same thing.
Git is a distributed version control system (DVCS). It helps developers track changes in code, work with branches, and collaborate by pushing and pulling updates between local and remote repositories. Git itself runs on your computer and doesn’t require the internet to work.
GitHub, on the other hand, is a cloud-based platform built on top of Git. It provides an online place to host repositories, making collaboration much easier. Beyond storing code, GitHub adds collaboration tools such as:
- Issues & Discussions – for bug tracking and communication.
- Pull Requests (PRs) – for code review and merging changes.
- Actions – for automating workflows like CI/CD.
- Projects & Labels – for organizing and managing work.
- Forks – for contributing to other projects.
In short: Git is the tool, GitHub is the platform. You use Git to manage your code versioning, and GitHub to share it, collaborate, and manage the bigger picture of software development.
Basic Git Commands
Git works like a camera taking snapshots of your project. Every time you make changes, you can decide whether to keep a “snapshot” (commit) so Git can track the history of your project. Here are some essential commands to get started:
Command | Description |
---|---|
git status |
Shows the current state of the working directory and staging area |
git add <file> |
Stages changes in a file (prepares it for the next commit) |
`git commit -m "" | Saves a snapshot of staged changes with a message describing the update |
git log |
Displays the history of commits with author, date, and commit messages |
git help |
Provides help for Git commands. Use git <command> --help for details. |
Introduction to GitHub
What is GitHub?
GitHub is a cloud-based platform built on top of Git. While Git handles version control, GitHub makes it easier to collaborate, share, and manage projects online. It provides a website, command-line tools, and workflows that bring developers, teams, and organizations together.
At its core, GitHub Enterprise focuses on five pillars: AI, Collaboration, Productivity, Security, and Scale.
AI – GitHub leverages generative AI through tools like Copilot, Copilot Chat, and Copilot Agents. These help write code faster, generate documentation, suggest fixes, and even improve security by catching issues early.
Collaboration – With features like Repositories, Issues, Pull Requests, and Discussions, GitHub makes teamwork seamless. Teams can work in parallel, review code efficiently, and shorten delivery cycles.
Productivity – Built-in CI/CD pipelines (GitHub Actions) automate repetitive tasks such as testing, building, and deploying software. This lets developers spend more time solving problems rather than managing workflows.
Security – GitHub integrates security at every stage of development with tools like CodeQL, Dependabot, secret scanning, and a security overview dashboard. This ensures vulnerabilities are detected and resolved early.
Scale – GitHub powers the world’s largest developer community with 100M+ developers and 420M+ repositories. Its extensible platform continuously evolves through contributions from open source and enterprise developers alike.
What is a repository?
A repository (repo) is the home for your project in Git or GitHub. It contains all of your project’s files along with their entire revision history, so you can track changes over time, restore older versions, and collaborate with others.
What is Gists?
Gists are a GitHub feature designed for sharing small pieces of code, notes, or configuration files in a lightweight way. Unlike full repositories, gists are quick to create and perfect for sharing short, useful snippets. Since they are essentially mini Git repositories, you can fork, clone, and even apply version control to them.
Key Features of Gists
-
Public and Secret Gists
- Public Gists: Visible to everyone and discoverable through GitHub search. Great for sharing examples, fixes, or snippets with the community.
- Secret Gists: Hidden from search results and not publicly listed. However, anyone with the link can view them. Useful for sharing code privately with a limited group.
- Version Control : Every change you make is tracked, so you can view edit history or roll back to previous versions.
- Forking and Cloning : Just like repositories, gists can be forked and cloned, enabling others to adapt your snippet to their needs.
- Embedding : Gists can be embedded directly into blogs, forums, or websites, making them ideal for tutorials or documentation.
- Markdown Support : Gists support Markdown, letting you add headings, links, rich text, or even images alongside your code for better context.
- Collaboration : Others can fork and comment on your gists, enabling lightweight collaboration around snippets and solutions.
Use Cases for Gists
- Sharing quick code examples or bug fixes
- Storing personal configuration files or scripts
- Creating templates for reusable code patterns
- Sharing error logs or debugging details with collaborators
- Embedding snippets into blogs, articles, or documentation
Important Notes
- Do not store sensitive information (like API keys, passwords, or secrets) in gists—even in secret gists.
- Secret ≠ Private: Secret gists are simply hidden, but anyone with the link can still access them.
Limitations of Gists
- Not suited for large projects or multi-file structures (use a repository instead).
- Secret gists are still accessible via URL, so they are not a substitute for true privacy.
What are Wikis?
A wiki in GitHub is a dedicated space within a repository for long-form documentation. While a README gives a quick overview, a wiki is ideal for detailed guides, design notes, or tutorials. It serves as a living knowledge base for your project. For private repos, only users with read access can view the wiki.
Components of the Github Glow
The GitHub Flow is a lightweight, branch-based workflow designed for continuous collaboration and deployment. It is built around three main components:
- Branches – A branch is where you do your work independently from the main codebase. You can experiment, fix bugs, or add features without affecting the default branch (main).
- Commits – A commit saves your changes to the repository, capturing a snapshot of what the code looked like at a certain point in time. Each commit includes metadata like the author, timestamp, and a unique identifier.
- Pull Requests – A pull request is how you propose changes to be merged into the default branch. It’s the place for discussion, feedback, code reviews, and automated checks before integration. GitHub also supports Draft Pull Requests, which let you open a pull request that's not yet ready for review.
File States in Git
Within a Git repository, every file goes through specific states as part of version control. Understanding these states is critical for working with Git effectively:
- Untracked – A new file that Git doesn’t know about yet. It hasn’t been added to version control.
-
Tracked – A file that Git is monitoring. Tracked files can exist in several substates:
- Unmodified – The file hasn’t changed since the last commit.
- Modified – The file has been changed but not yet staged.
- Staged – The modified file has been added to the staging area (git add) and is ready to be committed.
- Committed – The file is saved in the repository’s database as part of a commit (the latest snapshot).
GitHub Flow
The GitHub Flow is a simple, lightweight workflow designed to help you safely make and share changes. It’s widely used because it supports continuous integration and continuous delivery (CI/CD) while keeping things easy to manage.
Git Flow
While GitHub Flow is simple, Git Flow is a more structured branching model—suited for projects with scheduled or versioned releases. It introduces long-lived branches and specific rules for release management.
GitHub Flow vs Git Flow
Feature / Aspect | GitHub Flow 🌐 | Git Flow 🔀 |
---|---|---|
Purpose | Lightweight workflow for continuous delivery and collaboration. | Structured branching model for release-driven development. |
Default Branch |
main (or master in older repos). |
master (production) and develop (integration). |
Branch Types | Feature branches → Pull Requests → Merge into main . |
master , develop , feature/* , release/* , hotfix/* . |
Simplicity | Very simple and easy to adopt. | More complex, with multiple long-lived branches. |
Release Strategy | Continuous delivery—changes merged frequently. | Versioned releases with explicit preparation branches. |
Use Cases | Startups, small/medium teams, fast-moving projects. | Enterprises, regulated industries, projects needing predictable release cycles. |
History Management | Often uses squash merges or rebase for a clean history. | Requires merge commits to maintain branching structure. |
Speed vs Control | Prioritizes speed and agility. | Prioritizes control and release planning. |
GitHub Issues & Discussions
GitHub Issues are the primary way to track tasks, ideas, bugs, and feedback within a repository. They can be created in multiple ways and help teams stay organized. You can:
- Use labels, mentions, and reactions to categorize and prioritize work.
- Create issue templates to maintain consistency across contributions.
- Convert discussions into issues when an actionable task emerges.
GitHub Discussions, on the other hand, are designed for open conversations not tied directly to code. They work like a community forum where you can share ideas, ask questions, or provide feedback. Discussions can be public or private, depending on repository settings.
Key points about Discussions:
- Repository owners or users with Write access can enable Discussions.
- Any authenticated user with repo access can create a discussion.
- Maintainers can pin important discussions (e.g., announcements, FAQs, or active topics) for visibility.
- Discussions can be converted into issues when needed.
GitHub platform management
Managing Notifications and Subscriptions
Staying updated on important activity is key when working in GitHub. Notifications let you track updates across repositories, teams, and projects, while subscriptions help you control what you actually want to hear about.
You can subscribe to notifications for:
- Specific issues, pull requests, or gists
- Repository activity (issues, PRs, releases, discussions)
- Workflow statuses from GitHub Actions
- All activity across a repository
How it works:
- You’re automatically subscribed when you interact with something (e.g., commenting, opening an issue, or being assigned).
- You can also manually watch, unwatch, or customize your subscriptions to match your preferences.
- If updates become irrelevant, simply unsubscribe or adjust notification settings to reduce noise.
Subscribing to Threads and Finding Mentions
GitHub gives you fine-grained control over how you follow conversations and stay in the loop.
- Subscribing to threads – You can manually subscribe to any issue, pull request, or discussion—even if you weren’t part of the original conversation. Simply click Subscribe in the right-hand sidebar.
- Finding mentions – To locate conversations where you’ve been tagged, use the search qualifier:
mentions:<username>
This ensures you don’t miss discussions requiring your attention.
Filtering Notifications
You can adjust your watch settings on a repository to control the amount of updates you receive:
- Watching – Get notifications for all activity.
- Not watching – Only receive updates if you participate or are @mentioned.
- Ignore – Receive no notifications for that repository.
- Custom – Fine-tune notifications (issues only, PRs only, etc.).
Manage this by selecting Watch at the top of a repository page.
Configuring Notification Settings
GitHub also lets you choose where you receive notifications:
- Email – Delivered to your registered address.
- Web – Viewable directly in your GitHub dashboard.
- Mobile – Push notifications via the GitHub mobile app.
- Custom – Configure which events go to which channel.
These preferences can be managed under User Settings → Notifications.
What are GitHub Pages?
GitHub Pages is a free static site hosting service offered by GitHub. It allows you to create and host a personal, organizational, or project website directly from a GitHub repository.
- It serves HTML, CSS, and JavaScript files straight from your repo.
- Optionally, you can run the files through a build process (for example, with Jekyll) before publishing.
- You can specify a source branch and folder (like /docs) as the content root for your site.
- Once published, GitHub makes the site publicly accessible under a github.io domain or a custom domain you configure.
Introduction to GitHub's Products
GitHub accounts & plans
When working with GitHub, it’s important to understand two concepts:
- Account Types – define who owns resources (personal, organization, or enterprise).
- Plans – define what features are available (free or paid tiers).
GitHub Account Types
1.Personal Accounts
- Identity on GitHub (username + profile).
- Can own repositories, packages, and projects.
- Supports GitHub Free or GitHub Pro plans.
- Unlimited public and private repos (Free private repos have limited features).
2.Organization Accounts
- Shared accounts where teams collaborate across projects.
- Members log in with personal accounts; permissions are role-based (member, owner, security manager).
- Can own repositories, packages, and projects.
- Supports GitHub Free for Organizations or GitHub Team/Enterprise plans.
3.Enterprise Accounts
- Designed for large-scale organizations with multiple teams and orgs.
- Enterprise owners can manage orgs, enforce policies, and control billing centrally.
- Supports GitHub Enterprise (Cloud or Server).
GitHub Plans Comparison
Feature / Plan | Free (Personal/Org) | Pro (Personal) | Team (Organizations) | Enterprise (Cloud/Server) |
---|---|---|---|---|
Repositories | Unlimited public & private (limited features on private for Free) | Unlimited public & private | Unlimited public & private | Unlimited public & private |
Collaborators | Unlimited | Unlimited | Unlimited | Unlimited + org-wide policies |
Support | Community only | Email support | Email support | Dedicated Enterprise support |
GitHub Actions | 2,000 minutes/month | 3,000 minutes/month | 3,000 minutes/month | 50,000 minutes/month (Enterprise Cloud) |
Packages Storage | 500 MB | 2 GB | 2 GB | 50 GB (Enterprise Cloud) |
Codespaces | 120 core hours + 15 GB storage/month | 180 core hours + 20 GB storage/month | Org-level management + same limits as Pro | Custom enterprise limits |
Security Features | Dependabot alerts, 2FA enforcement | Same as Free | Required reviewers, protected branches, code owners | Advanced Security (CodeQL, secret scanning, policies) |
Collaboration Tools | Issues, PRs, Wikis, Pages (limited for Free orgs) | Wikis, Pages, Insights | Draft PRs, team reviewers, scheduled reminders, advanced insights | Centralized policies, GitHub Connect, EMU (Enterprise Managed Users) |
Best For | Individuals or small teams starting out | Individual developers needing advanced insights | Teams needing structured collaboration | Large orgs needing compliance, governance, and scale |
Hosting Options | GitHub.com | GitHub.com | GitHub.com | GitHub.com (Enterprise Cloud) or Self-hosted (Enterprise Server) |
Enterprise Managed Users (EMU)
Enterprise Managed Users allow organizations to control identities using their identity provider, enabling central access management and increased security.
GitHub Mobile vs GitHub Desktop
Feature / Tool | GitHub Mobile (iOS/Android) | GitHub Desktop (Windows/macOS) |
---|---|---|
Primary Use | On-the-go collaboration & notifications | Local Git workflow management |
Commit & Stage | ❌ No (can edit PR files only) | ✅ Yes |
Manage Notifications | ✅ Yes | ❌ No |
Review PRs & Issues | ✅ Yes | ✅ Yes |
Edit Files | ✅ In pull requests | ✅ Locally with commits |
Clone Repos | ❌ No | ✅ Yes |
Verify Sign-in | ✅ Yes | ❌ No |
Secure with 2FA | ✅ Yes | ❌ No |
CI Status View | ❌ No | ✅ Yes |
Platforms | iOS, Android | Windows, macOS |
License Usage Stats in Machine and Peripheral Devices
Tracking license usage is essential in GitHub Enterprise for both cost optimization and security compliance. Machine accounts and peripheral services can consume licenses just like regular users, which directly impacts enterprise costs and resource allocation.
Understanding Machine Accounts and Peripheral Services
Machine Accounts
- Special GitHub accounts used for automation, integrations, or running scripts.
- Commonly tied to CI/CD tools (e.g., GitHub Actions, Jenkins, CircleCI).
- Consume a GitHub license like any standard user.
- Act independently of human users.
Peripheral Services
- External services or tools interacting with GitHub via API requests.
- Examples include:
- CI/CD Pipelines (GitHub Actions, self-hosted runners, Jenkins).
- Security Tools (Dependabot, CodeQL, Snyk).
- Third-party Integrations (Slack, Jira, Datadog).
What is GitHub Copilot and Its Different Plans?
GitHub Copilot is your AI-powered pair programmer that helps you write code faster and smarter. Built by GitHub and OpenAI, it uses the OpenAI Codex and newer models like GPT-4o to generate real-time suggestions in dozens of programming languages.
Research shows that developers using GitHub Copilot experience:
- 46% of new code written by AI.
- 55% boost in productivity.
- 74% feel more focused on meaningful work.
Copilot integrates directly into popular IDEs like VS Code, Visual Studio, JetBrains, and Neovim, offering code autocompletion, explanations, and even test generation.
GitHub Copilot Features
- Copilot for Chat – AI-powered chat inside your IDE to explain code, generate tests, and suggest bug fixes.
- Copilot for Pull Requests – AI-generated PR descriptions and tags, powered by GPT-4.
- Copilot for the CLI – Helps compose complex terminal commands and flags, reducing time spent searching syntax.
GitHub Copilot Plans Comparison
Feature / Plan | Free (Individual) | Pro (Individual) | Pro+ (Individual) | Business (Teams/Orgs) | Enterprise (Large Orgs) |
---|---|---|---|---|---|
Code Completions | 2,000/month | Unlimited | Unlimited (priority capacity) | Unlimited | Unlimited (personalized w/ internal code) |
Chat Requests | 50/month | Unlimited | Unlimited | Unlimited | Unlimited |
AI Models | GPT-4o, Claude 3.5 | Latest models, priority access | Premium models, priority infra | Org-wide access to latest models | Fine-tuned org-specific models |
IDE Integration | VS Code, Visual Studio, JetBrains, Neovim | Same as Free | Same as Pro | Same as Pro + Mobile support | Deep GitHub integration + enterprise IDEs |
Test Generation | ❌ No | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes + org customization |
Pull Request Enhancements | ❌ No | ✅ Basic | ✅ Basic | ✅ AI-powered tags & security filtering | ✅ Advanced PR summaries & org-wide policies |
CLI Support | ❌ No | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Security Features | Basic (none) | Basic (none) | Basic (none) | Vulnerability filtering, IP indemnity, compliance tools | Advanced Security + org-wide governance |
Management Tools | ❌ No | ❌ No | ❌ No | Centralized management & policies | Enterprise-wide management & identity (EMU) |
Customization | ❌ No | ❌ No | ❌ No | ❌ Limited | ✅ Fine-tuned org/private models |
Best For | Beginners exploring AI coding | Individual developers needing unlimited AI help | Power users needing priority performance | Organizations needing secure collaboration | Enterprises needing personalization, compliance, and scale |
What is Code Scanning?
Code scanning is a GitHub feature that uses CodeQL to analyze the code in your repository for security vulnerabilities and coding errors. It helps developers catch problems early and ensure safer, cleaner code.
-
Availability:
- Enabled by default for all public repositories.
- Available for private repositories when GitHub Advanced Security is enabled.
-
How it works:
- When a potential vulnerability or error is detected, GitHub displays an alert in the repository’s Security tab.
- Once the issue is fixed, the alert is automatically closed.
- Developers can triage and prioritize fixes, preventing both existing and newly introduced issues.
-
Triggers for scanning:
-
on:push
– runs scans whenever new code is pushed. -
on:pull_request
– scans pull requests before merging, ensuring vulnerabilities aren’t introduced. - Scans can also be scheduled at specific days/times.
-
-
Powered by GitHub Actions:
- Code scanning workflows run on GitHub Actions.
- Each run consumes GitHub Actions minutes (free for public repositories and self-hosted runners).
- For private repositories, included usage depends on your GitHub plan.
- Usage beyond the free limit is controlled by spending limits (default $0/month for billed accounts, unlimited for invoiced customers).
- Minutes reset monthly, while storage usage accumulates until cleared.
What is GitHub Codespaces?
GitHub Codespaces is a cloud-hosted development environment powered by GitHub. It lets you spin up a fully configured, containerized workspace directly from a repository—without needing to set up dependencies or environments on your local machine.
Codespaces are configurable, so teams can define a repeatable environment for all developers, ensuring consistency across projects.
Codespace Lifecycle
- Create – Start a Codespace from GitHub.com, VS Code, or the GitHub CLI.
- Connect/Disconnect – You can disconnect and reconnect without interrupting processes.
- Stop/Restart – Resume where you left off without losing changes.
- Delete – Remove once work is complete (unpushed changes trigger a warning).
Ways to Create a Codespace
You can create a Codespace in four main ways:
- From a template repository – to start a new project.
- From a branch – for feature development.
- From a pull request – to explore or review in-progress work.
- From a specific commit – to investigate bugs at a certain point in history.
Key Features
- Long-running vs Temporary – Use Codespaces for short tests or extended feature development.
- Prebuilds – Admins can enable prebuilds to speed up environment setup.
- Timeouts – Codespaces stop after 30 minutes of inactivity. Data is preserved until explicitly deleted.
- Rebuilds – Rebuild to apply configuration changes. Cached images speed things up, while a full rebuild clears the cache for fresh setup.
- Retention – Inactive Codespaces are automatically deleted after 30 days (configurable).
What You Can Customize in GitHub Codespaces?
GitHub Codespaces is highly configurable, allowing you to personalize and optimize your development environment. Here are the key customization options:
- Settings Sync – Sync your VS Code settings between the desktop and web client.
- Dotfiles – Use a dotfiles repo to set up scripts, shell preferences, and custom configurations.
- Rename a Codespace – Change the autogenerated name to easily identify different Codespaces.
- Change Your Shell – Use your preferred shell (bash, zsh, etc.), set a new default, or configure via dotfiles.
- Change the Machine Type – Adjust CPU/RAM resources depending on workload.
- Set the Default Editor – Choose how Codespaces open:
- VS Code (desktop or web)
- JetBrains Gateway (for JetBrains IDEs)
- JupyterLab (for data science workflows)
- Set the Default Region – Decide where your data is stored geographically.
- Set the Timeout – Change the default 30-minute inactivity timeout to longer or shorter intervals.
- Configure Automatic Deletion – Define how long stopped Codespaces are retained (up to 30 days).
Project vs Projects (Classic)
Feature | Projects (New) | Projects (Classic) |
---|---|---|
Tables & Boards | Tables and Boards with flexible layouts (including Lists and Timeline). | Boards only. |
Data | Sort, rank, and group items using custom fields (text, number, date, iteration, single select). | Columns and Cards only. |
Insights | Create visuals and charts for historical and current progress tracking. | Simple progress bar. |
Automation | Advanced automation via GraphQL API, Actions, and column presets. | Limited automation with column presets when issues/PRs are added, edited, or closed. |
GitHub Actions with Workflows
GitHub Actions allows you to add powerful automation to your projects. By creating workflows, you can define tasks that run automatically when certain events occur in your repository.
- A workflow is made up of one or more jobs, and each job runs a series of steps.
- Workflows can be triggered by events such as issue creation, pull requests, or pushes to a branch.
Top comments (0)