Git & GitHub Tutorial


Beginners To Experts


The site is under development.

Git & GitHub Tutorial

What is Version Control?

Version control is a system that tracks changes to files over time so you can recall specific versions later. It's essential for collaborative work, backups, and tracking progress.

<!-- Initialize a Git repository in your project folder -->
$ git init  <!-- Creates a new local Git repository in the current directory -->
      

Types of Version Control Systems

Version control systems can be categorized into three types:

  • Local Version Control
  • Centralized Version Control (CVCS)
  • Distributed Version Control (DVCS)
Git is a distributed version control system.

<!-- Example of using a centralized system like SVN -->
svn checkout http://example.com/repo  <!-- Checks out a repository from a central server -->
      

Why Git?

Git is popular because it's fast, supports non-linear development (branches), works offline, and has robust merging and branching capabilities.

<!-- Cloning a Git repository -->
git clone https://github.com/user/project.git  <!-- Copies a Git repo from a remote server to your machine -->
      

Git vs Other VCS

Git offers better performance and flexibility compared to older systems like CVS and SVN. Unlike centralized systems, Git allows each user to have the full history of the project locally.

<!-- Show the full log of changes in Git -->
git log  <!-- Displays the history of commits in the repository -->
      

Installing Git

You can install Git by downloading it from the official website or using a package manager like `apt`, `brew`, or `choco`, depending on your OS.

<!-- Ubuntu/Debian -->
sudo apt install git  <!-- Installs Git using APT package manager -->

<!-- macOS -->
brew install git  <!-- Installs Git using Homebrew -->

<!-- Windows -->
choco install git  <!-- Installs Git using Chocolatey -->
      

Basic Git Terminology

Common terms in Git:

  • Repository: A project tracked by Git
  • Commit: A snapshot of your project
  • Branch: A separate line of development
  • Merge: Combining changes from different branches
  • Push: Sending commits to a remote repository
  • Pull: Fetching and merging changes from a remote repository

<!-- Basic Git workflow -->
git add .            <!-- Stages all modified files for commit -->
git commit -m \"Init\"  <!-- Commits the staged files with a message -->
git push origin main <!-- Pushes changes to the remote 'main' branch -->
      

Git Configuration (username, email)

This step is essential to associate your identity with your Git commits. You configure your name and email address globally using Git commands.

        
        git config --global user.name "Your Name" 
        
        
        git config --global user.email "your.email@example.com" 
      

Output: (No output if successful, values are set silently)

Generating SSH Keys

SSH keys allow secure communication with services like GitHub without using passwords every time.

        
        ssh-keygen -t ed25519 -C "your.email@example.com" 

        
        Enter file in which to save the key (/home/user/.ssh/id_ed25519): 

        
        Enter passphrase (empty for no passphrase): 
        Enter same passphrase again: 
      

Output: The key files will be generated in your .ssh directory.

Understanding .gitignore

The .gitignore file tells Git which files or directories to ignore in a repository.

        
        node_modules/ 
        *.log          
        .env           
        build/         
      

Output: These files won't be tracked or committed to your Git repository.

Initializing a Repository

Use this command to start a new Git repository in your current folder.

        
        git init 
      

Output: Initialized empty Git repository in /your/path/.git/

Cloning Repositories

To copy an existing repository from GitHub or another remote source, use the clone command.

        
        git clone https://github.com/username/repository.git 
      

Output: Directory "repository" created with all files from the remote repo.

Git Workflow Overview

The basic Git workflow involves editing files, staging changes, committing them, and pushing to a remote.

        
        git status 

        
        git add filename.txt 
        git add .            

        
        git commit -m "Your commit message" 

        
        git push origin main 
      

Output: Files are committed and pushed to the remote repository.

Working Directory and Staging Area

The working directory is where you edit files. The staging area is a place where you prepare a snapshot of changes before committing them. Git tracks these changes separately.

<!-- Check the current state of the working directory and staging area -->
git status  <!-- Shows untracked, modified, and staged files -->
      

Adding Files to Staging

To stage changes, you use the git add command. It tells Git to include changes in the next commit.

<!-- Add a specific file to the staging area -->
git add index.html  <!-- Stages 'index.html' for commit -->

<!-- Add all changes in the working directory -->
git add .  <!-- Stages all modified and new files -->
      

Making Commits

Committing saves your staged changes to the repository history. Each commit includes a message describing the change.

<!-- Commit staged changes with a message -->
git commit -m \"Add homepage layout\"  <!-- Commits the staged changes with a descriptive message -->
      

Viewing Commit History

You can view the history of commits in your repository using the git log command.

<!-- Show the full commit history -->
git log  <!-- Displays all previous commits with details like hash, author, and date -->

<!-- Show concise commit history -->
git log --oneline  <!-- Displays a simplified one-line summary of each commit -->
      

Understanding Commit IDs

Every commit in Git has a unique SHA-1 hash (commit ID) that identifies it. You can use this ID to reference or revert to a specific state.

<!-- Example of using commit ID to check out a previous state -->
git checkout a1b2c3d4  <!-- Switches to the commit with ID a1b2c3d4 (detached HEAD state) -->
      

Undoing Changes

Git provides commands to undo changes in the working directory, staging area, or even to reset commits.

<!-- Unstage a file -->
git reset index.html  <!-- Removes 'index.html' from staging but keeps the file changes -->

<!-- Discard changes in a file -->
git checkout -- index.html  <!-- Reverts 'index.html' to the last committed version -->

<!-- Undo the last commit but keep changes staged -->
git reset --soft HEAD~1  <!-- Moves HEAD back one commit, preserving the changes -->

<!-- Undo the last commit and discard changes -->
git reset --hard HEAD~1  <!-- Permanently removes the last commit and all associated changes -->
      

What is a Branch?

A branch in Git allows you to diverge from the main codebase to develop features or test ideas independently. The default branch is usually called main or master.

        
        git branch 

        
        * main
          feature-x
      

Creating and Switching Branches

You can create a new branch to work on a feature or bug fix. Switching to a branch allows you to work in that isolated environment.

        
        git branch feature-login 

        
        git checkout feature-login 

        
        git checkout -b feature-login 
      

Output: Switched to branch 'feature-login'

Merging Branches

After finishing work in a branch, you can merge it into another branch (typically the main branch).

        
        git checkout main 

        
        git merge feature-login 
      

Output: Fast-forward or Merge commit message depending on history.

Handling Merge Conflicts

Conflicts occur when the same parts of a file are changed in different branches. Git will ask you to resolve them manually.

        
        <<<<<<< HEAD 
        Current content
        =======
        Incoming content from merged branch
        >>>>>>> feature-login 

        
        git add conflicted-file.txt 

        
        git commit 
      

Output: Merge made successfully, or message about manual resolution.

Deleting Branches

Once a branch is merged and no longer needed, you can delete it to keep your repository clean.

        
        git branch -d feature-login 

        
        git branch -D feature-login 
      

Output: Deleted branch 'feature-login' (was 1a2b3c4d)

Branching Strategies

Using strategies helps teams manage development effectively. Common strategies include:

        
        main           
        develop        
        feature/*      
        release/*      
        hotfix/*       

        
        git checkout -b feature/add-login develop 
      

Output: Branching aligned with workflow structure and naming conventions.

Adding Remote Repositories

This involves linking a local Git repository to a remote one, such as a repository hosted on GitHub or GitLab. This enables collaboration and remote storage of your code.

# Command to add a remote repository
git remote add origin https://github.com/user/repo.git  # Adds a remote named 'origin' pointing to the given URL
      

Fetching vs Pulling

Fetching downloads the latest data from the remote repository without merging it into your local branch. Pulling is a combination of fetch and merge, which updates your local branch with remote changes.

# Fetching updates from remote without merging
git fetch origin  # Downloads commits, files, and refs from the remote repo

# Pulling updates (fetch + merge)
git pull origin main  # Fetches and merges changes from the 'main' branch of 'origin'
      

Pushing Changes

This sends your committed changes to the remote repository. You must push to share your updates with others.

# Pushing local changes to the remote repository
git push origin main  # Pushes your local 'main' branch to the remote 'origin'
      

Tracking Remote Branches

Remote tracking branches let you keep tabs on changes in the remote. When you clone a repository, Git automatically sets up tracking.

# Checking remote-tracking branches
git branch -r  # Lists all remote-tracking branches

# Setting up a local branch to track a remote branch
git branch --set-upstream-to=origin/main  # Sets the local branch to track 'origin/main'
      

Removing Remotes

You can remove a remote if it is no longer needed or if the URL has changed.

# Removing a remote
git remote remove origin  # Deletes the remote named 'origin'
      

Collaborating with Teams

Team collaboration with Git typically involves using feature branches, pull requests, and frequent pushes/pulls to ensure everyone stays in sync.

# Cloning a shared repository
git clone https://github.com/team/repo.git  # Copies the remote repository to your local system

# Creating a feature branch
git checkout -b feature-new-ui  # Creates and switches to a new branch for your feature

# Committing and pushing changes
git add .  # Stages all changes
git commit -m "Add new UI feature"  # Commits with a message
git push origin feature-new-ui  # Pushes your feature branch for review
      

Rebasing Explained

Rebasing is used to move or combine a sequence of commits to a new base commit. It provides a cleaner project history by linearizing commit sequences.

<!-- Rebase current branch onto 'main' -->
git rebase main  <!-- Applies current branch commits on top of 'main' branch -->

<!-- Abort the rebase if there are conflicts or issues -->
git rebase --abort  <!-- Cancels the rebase process and restores original state -->

<!-- Continue the rebase after resolving conflicts -->
git rebase --continue  <!-- Continues rebasing after resolving merge conflicts -->
      

Stashing Changes

Git stash allows you to save uncommitted changes temporarily so you can work on something else and come back later.

<!-- Stash current changes -->
git stash  <!-- Saves uncommitted changes to a stash stack -->

<!-- Apply the most recent stash -->
git stash apply  <!-- Applies the latest stash without removing it -->

<!-- Apply and remove the stash -->
git stash pop  <!-- Applies and deletes the most recent stash from the stack -->

<!-- List all stashes -->
git stash list  <!-- Shows all stashed changes -->
      

Tagging Commits

Tags are used to mark specific points in history as important. Often used to mark release versions.

<!-- Create a lightweight tag -->
git tag v1.0  <!-- Tags the latest commit with 'v1.0' -->

<!-- Create an annotated tag with a message -->
git tag -a v1.1 -m "Version 1.1 Release"  <!-- Annotated tag with description -->

<!-- Push tags to remote repository -->
git push origin v1.1  <!-- Pushes tag 'v1.1' to the remote -->

<!-- View all tags -->
git tag  <!-- Lists all available tags -->
      

Git Hooks Overview

Git hooks are scripts that run automatically on certain git events like commits or merges. They help automate tasks such as testing or formatting code.

<!-- Example hook location -->
.git/hooks/pre-commit  <!-- Script here runs before every commit -->

<!-- Example: pre-commit hook content -->
#!/bin/sh  <!-- Starts a shell script -->
npm test  <!-- Runs tests before allowing a commit -->
      

Git Submodules

Submodules allow you to keep a Git repository as a subdirectory of another repository. This is useful for managing dependencies.

<!-- Add a submodule -->
git submodule add https://github.com/example/lib.git lib-folder  <!-- Adds a repo as a submodule -->

<!-- Initialize submodules after cloning -->
git submodule init  <!-- Initializes local config for submodules -->

<!-- Update all submodules -->
git submodule update  <!-- Downloads the submodule content -->
      

Git Internals (Objects & References)

Git stores data in objects such as blobs, trees, and commits. References like branches and tags point to these objects.

<!-- Show internal object information -->
git cat-file -t HEAD  <!-- Shows the type of object at HEAD (usually a commit) -->

<!-- View content of an object -->
git cat-file -p HEAD  <!-- Prints the commit object at HEAD -->

<!-- List internal objects -->
git rev-parse HEAD  <!-- Returns the SHA-1 hash of the current commit -->
      

What is GitHub?

GitHub is a web-based platform that hosts Git repositories and provides tools for collaboration, issue tracking, pull requests, and project management.

        
        GitHub = Git (version control) + Hub (social coding platform)
        
      

Creating a GitHub Account

To use GitHub, you first need to create a free account on github.com.

        
        1. Go to <a href="https://github.com">github.com</a>
        2. Click <Sign up> at the top right corner.
        3. Enter your email, create a username and password.
        4. Verify your email address to activate your account.
      

GitHub Interface Overview

Once logged in, GitHub provides several interface elements:

        
        <Top Navigation Bar>       
        <Repositories Section>     
        <Profile Page>             
        <Settings>                 
      

Creating Your First Repository

A repository is where your project files and version history live. You can create one via the web interface.

        
        1. Click <New> under the Repositories tab.
        2. Enter a repository name (e.g., my-first-repo).
        3. Optionally add a description.
        4. Choose public or private.
        5. Optionally initialize with README.
        6. Click <Create repository>.
      

GitHub Profile Setup

You can customize your GitHub profile to showcase your work and identity.

        
        1. Click on your profile picture > Settings
        2. Update your Name, Bio, Location, Company, etc.
        3. Add a README to a repo named the same as your username to create a profile readme.
        
        
        <h1>Hi, I'm John Doe 👋</h1>
        <p>I build cool web apps using JavaScript and Python.</p>
      

Public vs Private Repositories

Public repositories are visible to everyone, while private repositories are accessible only to you and invited collaborators.

        
        <Public>      
        <Private>     

        
        1. Go to repository > Settings > Danger Zone
        2. Click <Change repository visibility>
        3. Select Public or Private
      

Cloning from GitHub

Cloning means creating a local copy of a GitHub repository. This allows you to make changes and push them back to GitHub.

# Clone a GitHub repository to your local machine
git clone https://github.com/username/repository.git  # Replace with your GitHub URL
      

Pushing Local Repositories

This allows you to take a repository from your local machine and push it to GitHub, usually after initializing it with git init.

# Initialize the local repository
git init  # Creates a new Git repository in the current directory

# Add remote origin to push to GitHub
git remote add origin https://github.com/username/repository.git  # Links to remote repo

# Add and commit changes
git add .  # Stages all files
git commit -m "Initial commit"  # Adds a message for the commit

# Push to GitHub
git push -u origin main  # Pushes your code to the 'main' branch on GitHub
      

Branch Management on GitHub

Branches on GitHub are useful for managing features, experiments, and bug fixes separately from the main codebase.

# Create and switch to a new branch
git checkout -b new-feature  # Creates and moves to 'new-feature' branch

# Push branch to GitHub
git push origin new-feature  # Sends the branch to GitHub

# View branches
git branch -a  # Shows all local and remote branches
      

Repository Settings Overview

GitHub repository settings allow you to manage features like branch protection, collaborators, repository visibility, and more. These are managed via GitHub UI, not Git CLI.

# No Git command for this. Use GitHub web interface:
# Go to GitHub.com > Open your repository > Click on "Settings"
# Adjust:
# - Description and topics
# - Branch protections
# - Access permissions
# - Secrets and webhooks
      

Adding README, License, and .gitignore

These files help in documentation, licensing, and excluding unnecessary files from being tracked by Git.

# Create a README file
echo "# Project Title" > README.md  # Adds a heading to the README

# Create a License file
echo "MIT License" > LICENSE  # Adds license text (replace with full license later)

# Create a .gitignore file
echo "node_modules/" > .gitignore  # Ignores the node_modules directory

# Add and commit these files
git add .  # Stages all new files
git commit -m "Add README, LICENSE, and .gitignore"  # Commit message
git push  # Pushes to GitHub
      

Using GitHub Templates

GitHub lets you mark a repository as a template, so others can generate new repositories based on it. This is useful for bootstrapping similar projects.

# No CLI command. Follow these GitHub UI steps:
# 1. Open the repository on GitHub
# 2. Go to "Settings"
# 3. Check the box "Template repository"

# To use a template:
# 1. Click "Use this template" on the repo page
# 2. Name your new repository
# 3. Click "Create repository from template"
      

What is Forking?

Forking creates a personal copy of someone else’s repository on your GitHub account. It allows you to freely make changes without affecting the original project.

<!-- No command for forking from CLI -->
<!-- Use GitHub UI: Click "Fork" button on the top-right of a repository page -->
      

Creating a Fork

When you click the "Fork" button on GitHub, it duplicates the repository under your account. You can then clone and work on it locally.

<!-- Clone the forked repository to your machine -->
git clone https://github.com/your-username/forked-repo.git  <!-- Downloads the forked repo to local system -->

cd forked-repo  <!-- Navigate into the forked project directory -->
      

Syncing a Forked Repository

Over time, the original (upstream) repository might have changes. You need to sync your fork to keep it up to date.

<!-- Add the original repository as a remote called 'upstream' -->
git remote add upstream https://github.com/original-owner/original-repo.git  <!-- Links the source repo as 'upstream' -->

<!-- Fetch the latest changes from upstream -->
git fetch upstream  <!-- Downloads changes from the original repository -->

<!-- Merge upstream changes into your local main branch -->
git checkout main  <!-- Switch to your main branch -->
git merge upstream/main  <!-- Merge changes from upstream into your branch -->
      

Opening a Pull Request

After making changes to your fork, you can open a Pull Request (PR) to propose merging your changes into the original repository.

<!-- Commit and push your changes to your fork -->
git add .  <!-- Stages all modified files -->
git commit -m "Added new feature"  <!-- Commits the changes with a message -->
git push origin main  <!-- Pushes changes to your fork's main branch -->

<!-- Open GitHub and click "Compare & pull request" button -->
<!-- Provide title, description, and submit the PR -->
      

Reviewing Pull Requests

Repository maintainers or collaborators can review PRs. They can comment, suggest changes, or approve them.

<!-- Use GitHub interface to review -->
<!-- Options include: Comment, Approve, or Request changes -->

<!-- Leave feedback in the Files Changed tab or main conversation -->
      

Merging Pull Requests

Once a pull request is reviewed and approved, it can be merged into the main branch of the original repository.

<!-- Use GitHub interface to merge -->
<!-- Options: Create a merge commit, squash, or rebase -->

<!-- Click "Merge pull request" and then "Confirm merge" -->
      

Creating and Managing Issues

Issues help track bugs, feature requests, or tasks within a repository.

        
        1. Navigate to the Issues tab in your repository.
        2. Click <New issue> button.
        3. Add a title and description explaining the problem or request.
        4. Submit the issue.

        
        Bug: Login page crashes on invalid input
      

Using Labels and Milestones

Labels categorize issues by type, priority, or status. Milestones group issues under a common goal or release.

        
        1. In the Issues tab, select an issue.
        2. Click <Labels> on the right sidebar.
        3. Choose or create labels like "bug", "enhancement", or "urgent".

        
        1. Click <Milestones> tab in Issues.
        2. Create a milestone (e.g., Version 1.0).
        3. Assign issues to this milestone to track progress.
      

Assigning Issues

You can assign issues to yourself or collaborators to indicate responsibility.

        
        1. Open an issue.
        2. Click <Assignees> on the right sidebar.
        3. Select yourself or team members from the list.

        
        Assigned to @username
      

GitHub Projects (Kanban Boards)

GitHub Projects offer Kanban-style boards to organize issues, pull requests, and notes.

        
        1. Go to the <Projects> tab in your repository or profile.
        2. Click <New project>.
        3. Choose "Board (Kanban)" template.
        4. Add columns like "To do", "In progress", "Done".
        5. Add cards by linking issues, PRs, or notes.
      

Issue Templates

Issue templates help standardize the information contributors provide when opening new issues.

        
        1. Create a <.github/ISSUE_TEMPLATE> folder in your repository.
        2. Add markdown files like "bug_report.md" and "feature_request.md".
        3. Each template pre-fills issue form with relevant fields.

        
        <!-- Bug Report Template -->
        ## Description
        Describe the bug here.

        ## Steps to Reproduce
        1. Step one
        2. Step two

        ## Expected Behavior
        What you expected to happen.
      

Closing and Reopening Issues

Issues can be closed when resolved and reopened if the problem persists.

        
        1. Go to the issue page.
        2. Click <Close issue> button at the bottom.

        
        1. Open a closed issue.
        2. Click <Reopen issue> button.

        
        git commit -m "Fix login bug. Closes #23" 
      

Introduction to GitHub Actions

GitHub Actions allow you to automate tasks like building, testing, and deploying code directly from your GitHub repository.

# GitHub Actions use YAML files to define workflows stored in .github/workflows/
# They run on GitHub-hosted runners or self-hosted runners to automate tasks
      

Creating Your First Workflow

Here is a simple workflow example that runs tests on every push to the main branch.

name: CI  # Names the workflow

on:  # Defines events that trigger the workflow
  push:  # Runs when code is pushed
    branches: [ main ]  # Only on pushes to 'main' branch

jobs:  # Defines the jobs in this workflow
  build:  # Job named 'build'
    runs-on: ubuntu-latest  # Runs on the latest Ubuntu runner

    steps:  # Steps to run in this job
      - uses: actions/checkout@v3  # Checks out the repo code

      - name: Run tests  # Step to run tests
        run: |
          echo "Run your test commands here"  # Placeholder for test commands
      

Using Marketplace Actions

GitHub Marketplace offers pre-built actions that simplify your workflow setup, such as setting up languages, sending notifications, or deploying.

# Example: Using the setup-node action to set Node.js version
- uses: actions/setup-node@v3  # Uses the Node.js setup action
  with:
    node-version: '16'  # Specifies Node.js version 16
      

Continuous Integration Basics

CI means automatically building and testing your code after every change to detect problems early.

# A typical CI workflow runs on every push or pull request
on:
  [push, pull_request]  # Triggers on push or PR

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3  # Checkout code
      - name: Install dependencies
        run: npm install  # Install project dependencies
      - name: Run tests
        run: npm test  # Run your test suite
      

Automating Tests and Deployments

You can extend workflows to deploy your code automatically after successful tests.

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Build project
        run: npm run build  # Build your project

      - name: Deploy
        run: ./deploy.sh  # Run a deploy script (replace with your deployment commands)
      

Managing Secrets in Workflows

Secrets like API keys or passwords are stored securely in GitHub and accessed in workflows using environment variables.

# To use secrets in a workflow:
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Deploy with secret
        env:
          API_KEY: ${{ secrets.API_KEY }}  # Access secret named API_KEY
        run: |
          echo "Using API key $API_KEY to deploy"  # Example usage of secret
      

Inviting Collaborators

You can invite other GitHub users to collaborate on your repository by adding them as collaborators.

<!-- On GitHub repository page: Go to Settings > Manage Access > Invite a collaborator -->
<!-- Enter GitHub username or email, then send invite -->
      

Managing Access Levels

Collaborators can have different permission levels like Read, Write, or Admin, controlling what actions they can perform.

<!-- Access levels explanation -->
<!-- Read: Can view and clone repo -->
<!-- Write: Can push changes and create branches -->
<!-- Admin: Full control including managing settings and collaborators -->
      

Branch Protection Rules

Branch protection rules enforce workflows and restrictions on branches to prevent unwanted changes.

<!-- On GitHub: Settings > Branches > Add branch protection rule -->
<!-- Example rules: Require pull request reviews before merging -->
<!-- Prevent force pushes or deletions -->
      

Required Reviews and Status Checks

You can require code reviews and passing status checks before pull requests can be merged.

<!-- Enable required reviews in branch protection settings -->
<!-- Integrate CI tools (like GitHub Actions) for automated status checks -->
<!-- Merging blocked until reviews and checks pass -->
      

Managing Teams and Organizations

Within organizations, teams can be created with specific access permissions to multiple repositories.

<!-- Organization owner creates teams in GitHub Organization Settings -->
<!-- Assign repositories and permissions per team -->
<!-- Simplifies managing large groups of collaborators -->
      

Auditing Access and Activity

GitHub provides audit logs to track collaborator activities, including access changes, pushes, and pull requests.

<!-- Available for organizations on GitHub Enterprise or paid plans -->
<!-- Access audit logs via Organization Settings > Audit Log -->
<!-- Helps ensure security and compliance -->
      

What is GitHub Pages?

GitHub Pages is a static site hosting service that lets you publish web pages directly from a GitHub repository.

<!-- GitHub Pages hosts static HTML, CSS, JS files directly from your repo -->
<!-- Great for project sites, portfolios, and documentation -->
      

Setting Up a GitHub Pages Site

To create a GitHub Pages site, you enable it in your repository settings and choose a source branch.

<!-- On GitHub repo: Settings > Pages > Source -->
<!-- Select branch (main or gh-pages) and folder (root or /docs) -->
<!-- Save changes to publish your site -->
      

Custom Domains on GitHub Pages

You can link a custom domain name to your GitHub Pages site by configuring DNS records.

<!-- Add a CNAME file with your custom domain to your repo root -->
<!-- Example content of CNAME file -->
mycustomdomain.com

<!-- Configure DNS: Create CNAME or A records pointing to GitHub Pages servers -->
      

Markdown Basics for Docs

Markdown is a lightweight markup language used for writing formatted text, often used in README files and documentation.

<!-- Example markdown syntax: -->
# Heading 1
## Heading 2
**Bold text**
*Italic text*
- List item 1
- List item 2

<!-- Rendered as HTML by GitHub automatically -->
      

Creating Wikis and GitHub Docs

GitHub provides built-in wikis for repositories, and you can also maintain docs using markdown files in a docs folder.

<!-- Wiki tab in GitHub repo lets you create and edit pages -->
<!-- Docs can live in a /docs folder with markdown files -->
<!-- Both support collaborative editing and version control -->
      

Using Jekyll with GitHub Pages

Jekyll is a static site generator integrated with GitHub Pages, allowing you to build more complex, templated websites.

<!-- Add _config.yml to configure Jekyll site -->
<!-- Use layouts, includes, and markdown files -->
<!-- GitHub Pages automatically builds and serves your Jekyll site -->
      

Installing GitHub CLI

The GitHub CLI (gh) tool allows you to interact with GitHub from your terminal.

        
        brew install gh

        
        sudo apt install gh

        
        gh --version
      

Common GitHub CLI Commands

Some useful commands for daily GitHub tasks using CLI.

        
        gh repo clone username/repository

        
        gh repo create my-new-repo --public

        
        gh issue list

        
        gh issue create --title "Bug report" --body "Description of the bug"

        
        gh pr create --title "Feature X" --body "Add new feature X"
      

Authenticating CLI

Before using gh commands, you need to authenticate with your GitHub account.

        
        gh auth login

        

        
        gh auth status
      

Automating Tasks with CLI

You can script and automate repetitive GitHub workflows using the CLI.

        
        gh issue create --title "Automated issue" --body "Created by script"

        
        gh repo create auto-repo --public --description "Repo created by script"
      

Introduction to GitHub REST API

The GitHub REST API allows programmatic access to GitHub data and actions.

        
        curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/users/username

        
        {
          "login": "username",
          "id": 123456,
          "public_repos": 10,
          ...
        }
      

Using GraphQL with GitHub API

GitHub’s GraphQL API allows more flexible queries than REST.

        
        {
          user(login: "username") {
            name
            bio
            repositories(first: 5) {
              nodes {
                name
                description
              }
            }
          }
        }

        
      

Two-Factor Authentication (2FA)

2FA adds an extra layer of security by requiring a second form of verification besides your password.

# To enable 2FA on GitHub:
# 1. Go to GitHub Settings > Security > Two-factor authentication
# 2. Choose authentication method (e.g., authentication app or SMS)
# 3. Follow setup instructions to secure your account
      

Managing SSH Keys Securely

SSH keys allow secure access to GitHub without using passwords. Always protect your private keys.

# Generate a new SSH key pair
ssh-keygen -t ed25519 -C "your_email@example.com"  # Creates a new SSH key with your email

# Start the ssh-agent in the background
eval "$(ssh-agent -s)"  # Starts the ssh-agent

# Add your SSH private key to the ssh-agent
ssh-add ~/.ssh/id_ed25519  # Adds the private key to the agent

# Copy the public key to add to GitHub
cat ~/.ssh/id_ed25519.pub  # Displays the public key for GitHub settings
      

Using Personal Access Tokens

Tokens replace passwords for GitHub API and Git CLI operations, especially when 2FA is enabled.

# To create a personal access token (PAT):
# 1. Go to GitHub Settings > Developer settings > Personal access tokens
# 2. Click "Generate new token"
# 3. Select scopes (permissions) for the token
# 4. Copy the token and use it instead of a password for Git operations
# Example usage:
git clone https://username:<token>@github.com/username/repo.git  # Use token in place of password
      

Enabling Branch Protection

Branch protection rules help prevent force pushes and require reviews before merging changes on critical branches.

# To enable branch protection:
# 1. On GitHub, go to your repository > Settings > Branches
# 2. Under "Branch protection rules", click "Add rule"
# 3. Specify the branch name pattern (e.g., main)
# 4. Enable protections like:
#    - Require pull request reviews before merging
#    - Require status checks to pass before merging
#    - Restrict who can push to matching branches
      

Code Scanning and Alerts

GitHub’s code scanning automatically analyzes your code for security vulnerabilities and bugs.

# To enable code scanning:
# 1. Go to your GitHub repository > Security > Code scanning alerts
# 2. Set up a scanning workflow or use GitHub Advanced Security features
# 3. Review alerts and fix issues found in your codebase
      

Secret Scanning in Repositories

Secret scanning helps detect accidentally committed sensitive data like API keys and passwords.

# To enable secret scanning:
# 1. Go to your GitHub repository > Settings > Security > Secret scanning
# 2. Enable scanning for your repository
# 3. GitHub will scan commits and alert if secrets are detected
      

Centralized Workflow

This workflow uses a single central repository where all collaborators push changes directly to main branches.

<!-- Developers clone the central repo -->
<!-- Make changes locally, then git push to central repo -->
<!-- Simple but risks conflicts if multiple push at once -->
      

Feature Branch Workflow

Each feature is developed in its own branch, isolated from main branches, and merged back when ready.

<!-- Create a feature branch -->
git checkout -b feature/my-feature

<!-- Work and commit on feature branch -->
git add .
git commit -m "Add new feature"

<!-- Merge feature branch back to main -->
git checkout main
git merge feature/my-feature
      

Gitflow Workflow

A robust branching model with dedicated branches for features, releases, and hotfixes.

<!-- Main branches: main (production), develop (integration) -->
<!-- Feature branches branch off develop -->
<!-- Release branches prepare production releases -->
<!-- Hotfix branches fix production issues -->
      

Forking Workflow

Each contributor forks the main repo, works on changes, then submits pull requests for review.

<!-- Fork repo on GitHub -->
<!-- Clone your fork locally -->
git clone https://github.com/yourusername/repo.git

<!-- Push changes to your fork and open pull request -->
git push origin your-branch
      

Commit Message Conventions

Use clear, concise commit messages to describe changes for easier collaboration.

<!-- Format: -->
<!-- feat: Add new login feature -->
<!-- fix: Correct typo in README -->
<!-- docs: Update API documentation -->
<!-- style: Format code with Prettier -->
      

Code Review Best Practices

Code reviews improve code quality and knowledge sharing; reviewers should provide constructive feedback.

<!-- Review for correctness, style, performance, and security -->
<!-- Ask questions if unclear -->
<!-- Approve only when ready -->
<!-- Keep comments respectful and clear -->
      

Undoing Commits and Changes

You can undo recent commits or staged changes with these commands.

        
        git reset --soft HEAD~1

        
        git reset --hard HEAD~1

        
        git reset HEAD filename.txt

        
        git checkout -- filename.txt
      

Resolving Merge Conflicts

Merge conflicts occur when changes collide; you must manually fix and commit them.

        
        git status

        
        <<<<<<< HEAD
        Your changes here
        =======
        Incoming changes here
        >>>>>>> branch-name

        
        git add filename.txt

        
        git commit
      

Recovering Deleted Branches

If you deleted a branch accidentally, you can recover it if the commits still exist.

        
        git reflog

        
        git branch feature <commit-hash>

        
        git checkout feature
      

Fixing Detached HEAD

A detached HEAD means you are not on a branch; you can fix it by creating a branch.

        
        git checkout -b new-branch

        
        git checkout main
      

Cleaning Up Repositories

Remove unnecessary files and optimize the repository.

        
        git clean -f

        
        git clean -fd

        
        git gc --prune=now --aggressive
      

Handling Large Files with Git LFS

Git Large File Storage (LFS) manages big files efficiently in Git repos.

        
        git lfs install

        
        git lfs track "*.psd"

        
        git add .gitattributes

        
        git commit -m "Track PSD files with Git LFS"

        
        git push origin main
      

Collaboration Strategies

Effective collaboration in Git requires clear workflows such as Git Flow, feature branching, or trunk-based development.

# Example: Using feature branches for collaboration
git checkout -b feature/new-feature  # Create and switch to a new feature branch

# Work on the feature and commit changes
git add .  # Stage changes
git commit -m "Add new feature implementation"  # Commit changes

# Push the feature branch to remote
git push origin feature/new-feature  # Push branch for review and collaboration
      

Code Reviews and Pull Requests

Pull Requests (PRs) let team members review, discuss, and approve code changes before merging into main branches.

# Typical Pull Request workflow:
# 1. Push your branch to remote
git push origin feature/new-feature

# 2. Open a PR on GitHub from feature/new-feature to main branch
# 3. Team members review and comment on PR
# 4. After approval, merge PR to main branch via GitHub UI or CLI
      

Managing Multiple Contributors

Managing many contributors involves setting clear roles, permissions, and ensuring contributors work on separate branches.

# Example: Add a contributor to your GitHub repo
# 1. Go to repository Settings > Manage access
# 2. Invite collaborators by username or email
# 3. Assign roles: Admin, Write, Read, etc.

# Use branch permissions to protect main branches
      

Communication Best Practices

Good communication reduces conflicts and improves team productivity. Use clear commit messages, descriptive PR titles, and status updates.

# Example commit message style:
git commit -m "Fix bug: resolve issue with login validation"  # Clear and descriptive

# Use issue comments and PR discussions for detailed explanations
# Keep team updated on progress via Slack, Teams, or emails
      

Handling Releases and Tags

Tags mark specific points in history as releases, helping track versions and deployments.

# Create a new annotated tag for a release
git tag -a v1.0.0 -m "Release version 1.0.0"  # Tag current commit with message

# Push tags to remote
git push origin v1.0.0  # Share tag with collaborators

# List tags
git tag  # Show all tags in repository
      

Using Protected Branches

Protected branches prevent force pushes, require PR reviews, and enforce status checks to safeguard important branches like main.

# To enable branch protection on GitHub:
# 1. Go to repository Settings > Branches
# 2. Add branch protection rules for branches like main or release
# 3. Enable settings such as:
#    - Require pull request reviews before merging
#    - Require status checks to pass before merging
#    - Restrict who can push to the branch
      

GitHub Sponsors

GitHub Sponsors allows you to financially support open source contributors directly through GitHub.

<!-- Visit sponsors.github.com to set up sponsorship -->
<!-- Users can sponsor individuals or projects -->
<!-- Helps fund ongoing open source development -->
      

GitHub Discussions

Discussions provide a forum-like space within repositories for community engagement beyond issues and pull requests.

<!-- Enable Discussions tab in repo settings -->
<!-- Use to ask questions, share ideas, and collaborate -->
<!-- Categories and labels help organize discussions -->
      

GitHub Codespaces Overview

Codespaces provide instant, cloud-hosted development environments accessible directly from GitHub.

<!-- Click the 'Code' button in GitHub repo, then 'Open with Codespaces' -->
<!-- Full VS Code experience in browser or desktop app -->
<!-- Preconfigured dev environments speed up onboarding -->
      

Using GitHub Projects Advanced

Advanced Projects enable customizable Kanban boards and workflows for issue and pull request tracking.

<!-- Create projects from repo or organization level -->
<!-- Automate workflows with custom fields and automation rules -->
<!-- Integrate with issues, pull requests, and external tools -->
      

GitHub Templates and Actions Marketplace

Templates provide reusable repository setups, and Actions Marketplace offers automation workflows you can add to your repos.

<!-- Use repo templates to quickly create new projects -->
<!-- Explore Actions Marketplace for CI/CD, linting, and more -->
<!-- Customize workflows using YAML configuration -->
      

Managing GitHub Packages

GitHub Packages is a package hosting service that supports multiple package types for easy distribution.

<!-- Publish and consume packages within GitHub repos -->
<!-- Supports npm, Docker, Maven, NuGet, and more -->
<!-- Control access and versioning via GitHub permissions -->
      

CI/CD Concepts

Continuous Integration (CI) automates testing of code changes, and Continuous Deployment (CD) automates releasing code to production.

        
        

        
      

Setting Up CI with GitHub Actions

GitHub Actions lets you define workflows that run on events like pushes or pull requests.

        
        name: CI

        on:
          push:
            branches: [ main ]
          pull_request:
            branches: [ main ]

        jobs:
          build:
            runs-on: ubuntu-latest

            steps:
            - uses: actions/checkout@v2
              # Checkout repository code

            - name: Set up Node.js
              uses: actions/setup-node@v2
              with:
                node-version: '14'
              # Setup Node.js environment

            - name: Install dependencies
              run: npm install
              # Install project dependencies

            - name: Run tests
              run: npm test
              # Run unit tests
      

Automating Builds and Tests

Automate building your software and running tests to ensure quality before deployment.

        
        

        
        - name: Run lint
          run: npm run lint

        - name: Build project
          run: npm run build
      

Deployment Workflows

Define workflows to deploy your application automatically after successful tests.

        jobs:
          deploy:
            needs: build
            runs-on: ubuntu-latest
            steps:
            - uses: actions/checkout@v2
              # Checkout code for deployment

            - name: Deploy to server
              run: |
                ssh user@server "cd /var/www/app && git pull && systemctl restart app"
              # Deploy code by SSH and restart service
      

Monitoring Workflow Runs

Monitor your CI/CD workflows via GitHub Actions UI to check success or failure of each job.

        
        
        
      

Rollbacks and Notifications

Set up notifications and rollback procedures in case deployments fail.

        
        - name: Notify on failure
          if: failure()
          uses: some-notification-action@v1
          with:
            message: "Deployment failed"

        
        ssh user@server "cd /var/www/app && git reset --hard HEAD~1 && systemctl restart app"
      

Git Object Model

Git stores data as objects: blobs (file contents), trees (directories), commits, and tags.

# List objects in Git database
git cat-file -p <object-hash>  # View content of an object by hash

# Example: show the commit object for HEAD
git cat-file -p HEAD  # Displays commit metadata and tree hash
      

Understanding Commits and Trees

A commit points to a tree object representing the snapshot of the project at that commit, plus metadata like author and message.

# Show the tree object linked to a commit
git cat-file -p <commit-hash>  # Shows commit details including tree hash

# Show tree contents
git cat-file -p <tree-hash>  # Lists files and subtrees in the tree object
      

How Git Stores Data

Git stores content as compressed objects in the .git/objects directory, using SHA-1 hashes as keys.

# Explore raw Git objects directory
ls .git/objects  # Shows directories named after first 2 chars of hashes

# Objects are stored as compressed files by hash suffix
# Git reconstructs repository state using these objects
      

Packfiles and Garbage Collection

Git packs multiple objects into packfiles for efficient storage and runs garbage collection to clean unused objects.

# Manually run garbage collection
git gc  # Compresses objects and cleans unreferenced data

# View packfiles
ls .git/objects/pack  # Shows packfiles storing compressed objects

# To repack objects manually
git repack -a -d --depth=250 --window=250  # Optimizes packfiles
      

Reference Logs

Reflogs record updates to branch tips and other refs, allowing recovery of lost commits.

# Show reflog entries
git reflog  # Lists recent updates to HEAD

# Recover a commit using reflog
git checkout <reflog-hash>  # Checkout a commit from reflog if lost
      

Low-Level Git Commands

Low-level commands allow direct interaction with Git objects and refs for advanced operations.

# Show object type
git cat-file -t <object-hash>  # Outputs type: commit, tree, blob, or tag

# Create a new blob object from a file
git hash-object -w <filename>  # Writes file content as a blob to object store

# Update refs manually
git update-ref refs/heads/new-branch <commit-hash>  # Create/update branch pointer
      

Git Aliases

Aliases allow you to create shortcuts for frequently used Git commands to save time.

<!-- Create an alias for git status -->
git config --global alias.st status

<!-- Now you can type git st instead of git status -->
      

Configuring Git Hooks

Git hooks are scripts that run automatically on certain Git events like commits or pushes.

<!-- Example: pre-commit hook to run tests before commit -->
<!-- Create file .git/hooks/pre-commit and make it executable -->
<!--!/bin/sh
npm test
if [ $? -ne 0 ]; then
  echo "Tests failed, commit aborted."
  exit 1
fi
      

Custom Diff and Merge Tools

You can configure Git to use external tools for comparing and merging files.

<!-- Set custom diff tool (e.g., meld) -->
git config --global diff.tool meld

<!-- Use custom merge tool -->
git config --global merge.tool meld

<!-- Launch diff tool -->
git difftool

<!-- Launch merge tool -->
git mergetool
      

Git Templates and Ignore Rules

Use templates for new repositories and .gitignore files to exclude files from tracking.

<!-- Set a global gitignore file -->
git config --global core.excludesfile ~/.gitignore_global

<!-- Example .gitignore_global content -->
node_modules/
.DS_Store
*.log
      

Using Git with Other Tools

Git integrates well with various IDEs, CI/CD systems, and third-party tools to improve workflow.

<!-- Example: integrating Git with VS Code -->
<!-- Open project in VS Code, use built-in Git features -->

<!-- Example: setting up Git with Jenkins for CI -->
<!-- Jenkins pulls repo and runs build scripts automatically -->
      

Performance Tuning

Configure Git settings for better performance on large repositories.

<!-- Increase pack window memory for faster operations -->
git config --global pack.windowMemory "100m"

<!-- Increase delta cache size -->
git config --global pack.deltaCacheSize "100m"

<!-- Enable multi-threading -->
git config --global pack.threads "4"
      

Setting Up Open Source Repo

Start by creating a public repository for your open source project and initialize it properly.

        

        
        git clone git@github.com:username/repo-name.git

        
        echo "# Project Title" > README.md

        
        git add README.md
        git commit -m "Add README"
        git push origin main
      

Creating Contribution Guidelines

Contribution guidelines help contributors understand how to contribute properly.

        
        echo "# Contribution Guidelines" > CONTRIBUTING.md

        

        
        git add CONTRIBUTING.md
        git commit -m "Add contribution guidelines"
        git push origin main
      

Managing Community and Contributors

Engage with contributors through issues, discussions, and pull requests.

        

        

        

        
      

Using Issue and PR Templates

Create templates to standardize issues and pull requests.

        
        <!-- Example bug report template content -->

        
        <!-- Example PR template content -->

        
        git add .github/ISSUE_TEMPLATE/bug_report.md .github/PULL_REQUEST_TEMPLATE.md
        git commit -m "Add issue and PR templates"
        git push origin main
      

License and Code of Conduct

Choose an open source license and add a code of conduct to set community standards.

        
        echo "MIT License content" > LICENSE

        
        echo "# Code of Conduct" > CODE_OF_CONDUCT.md

        
        git add LICENSE CODE_OF_CONDUCT.md
        git commit -m "Add license and code of conduct"
        git push origin main
      

Promoting Your Project

Promote your open source project via social media, blogs, and GitHub topics.

        

        

        

        
      

Introduction to GitHub Enterprise

GitHub Enterprise provides a self-hosted or cloud-hosted platform tailored for large organizations with enhanced security and control.

# Example: Connect to GitHub Enterprise instance via Git
git remote add enterprise <https://github.enterprise.example.com/username/repo.git>  # Add remote for enterprise repo

git push enterprise main  # Push code to Enterprise remote repository
      

Managing Organizations and Teams

Organizations group repositories and teams, managing access and permissions centrally.

# Add a team to an organization on GitHub Enterprise via API example
curl -H "Authorization: token <YOUR_TOKEN>" \
  -X POST \
  -d '{"name":"developers","permission":"push"}' \
  https://github.enterprise.example.com/api/v3/orgs/<org-name>/teams

# Assign repositories to teams to control access
      

Enterprise Security Features

GitHub Enterprise supports security features like SAML SSO, LDAP integration, and audit logs.

# Enable SAML single sign-on for your organization (via GitHub UI)
# This ensures all users authenticate through your enterprise identity provider.

# Audit logs track all user and repository activities for compliance.
      

Auditing and Compliance

Enterprise offers detailed audit logs and compliance reports to meet organizational policies.

# Access audit logs on GitHub Enterprise UI
# Use API to fetch audit logs for automated monitoring:
curl -H "Authorization: token <YOUR_TOKEN>" \
  https://github.enterprise.example.com/api/v3/orgs/<org-name>/audit-log

# Review logs for unauthorized access or changes
      

Managing Large Repositories

Enterprise supports handling large repos with Git LFS and repository archiving features.

# Use Git Large File Storage (LFS) for big assets
git lfs install  # Initialize Git LFS in your repo

git lfs track "*.psd"  # Track Photoshop files with LFS

git add .gitattributes  # Add LFS tracking rules to repo
git commit -m "Track large binary files with Git LFS"

git push enterprise main  # Push large files managed by LFS to Enterprise repo
      

Integrations and Marketplace

GitHub Enterprise supports marketplace apps and custom integrations for CI/CD, code quality, and more.

# Install a GitHub App via Enterprise Marketplace (via UI)
# Example: Integrate CI tool (like Jenkins or CircleCI) with Enterprise repos

# Use GitHub Actions in Enterprise for automation
# Define workflows in .github/workflows/ directory in your repo
      

Migrating Repositories to GitHub

Move your existing Git repositories from other hosts or local systems to GitHub easily.

<!-- Clone existing repository locally -->
git clone <existing-repo-url>

<!-- Add new GitHub remote -->
git remote add origin <github-repo-url>

<!-- Push all branches and tags to GitHub -->
git push -u origin --all
git push -u origin --tags
      

Exporting Git Repositories

Export your repository data for backups or migration using Git bundle files.

<!-- Create a bundle file of the repository -->
git bundle create repo.bundle --all

<!-- Share repo.bundle or store as backup -->
      

Backing Up GitHub Repos

Regularly backup GitHub repositories by cloning or using GitHub APIs.

<!-- Clone repo locally as backup -->
git clone --mirror <github-repo-url>

<!-- Use GitHub API or third-party tools for scheduled backups -->
      

Importing Projects from Other Platforms

GitHub provides import tools to migrate projects from services like Bitbucket, GitLab, or SVN.

<!-- Use GitHub's import repository tool at https://github.com/new/import -->
<!-- Provide source repo URL and credentials -->

<!-- Follow steps to import issues, pull requests, and history -->
      

Archiving Repositories

Archive repositories on GitHub to make them read-only but still accessible.

<!-- In GitHub repo settings -->
<!-- Scroll to "Danger Zone" and select "Archive this repository" -->

<!-- Archived repos cannot be pushed to or edited -->
      

Disaster Recovery

Prepare for data loss by having multiple backups and recovery plans in place.

<!-- Keep local clones and bundle backups offsite -->
<!-- Use automated backup scripts or services -->
<!-- Test recovery procedures regularly -->
      

What are Webhooks?

Webhooks are HTTP callbacks triggered by events in GitHub that notify your external services in real-time.

        
        
      

Setting Up Webhooks

You configure webhooks in your GitHub repository settings to send event data to your server.

        
        
        
        
        
        
        
      

Popular GitHub Integrations

Many apps integrate with GitHub via APIs or webhooks to automate workflows, e.g., Slack, Jenkins, CircleCI.

        
        
        

        
      

Using Zapier and IFTTT

Zapier and IFTTT help automate tasks by connecting GitHub with many other apps without coding.

        
        

        
      

Custom Automation with Webhooks

Build your own server to handle webhook events and automate workflows as needed.

        <!-- Sample Node.js Express webhook handler -->
        const express = require('express');
        const app = express();

        app.use(express.json());  // Parse JSON payloads

        app.post('/webhook', (req, res) => {
          const event = req.headers['x-github-event'];
          const payload = req.body;

          console.log('Received event:', event);
          // Process event (e.g., trigger CI, update DB, notify team)

          res.status(200).send('Webhook received');
        });

        app.listen(3000, () => console.log('Server listening on port 3000'));
      

Troubleshooting Webhooks

Common issues include payload delivery failures, incorrect URLs, or secret token mismatches.

        
        
        
        
      

Exploring Marketplace

The GitHub Marketplace offers apps and actions to enhance workflow automation, CI/CD, security, and more.

# Browse marketplace in the browser:
# https://github.com/marketplace

# Example: Install an action for automated code review in your repo
# Use the GitHub UI or add a workflow file referencing the action
      

Popular GitHub Apps

Popular apps include Dependabot for dependency updates, Snyk for security scanning, and CodeQL for code analysis.

# Enable Dependabot for automated dependency updates
# Create dependabot.yml in .github directory with rules

# Example snippet in dependabot.yml:
version: 2
updates:
  - package-ecosystem: "npm"
    directory: "/"  # Location of package.json
    schedule:
      interval: "daily"
      

Code Quality and Security Tools

Tools like CodeQL and Snyk help identify vulnerabilities and enforce security best practices.

# Example: Using CodeQL in GitHub Actions workflow
name: "CodeQL Analysis"
on: [push, pull_request]
jobs:
  analyze:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Initialize CodeQL
        uses: github/codeql-action/init@v2
      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v2
      

Project Management Apps

Apps like ZenHub and Jira integrate with GitHub to manage issues, sprints, and project boards.

# Example: Link Jira issues to GitHub commits
# Use smart commits in commit messages like:
git commit -m "JIRA-123 Fix login bug"

# Jira app updates issue status automatically
      

Testing and Deployment Tools

Marketplace tools help automate testing, build, and deployment pipelines (e.g., CircleCI, Travis CI, GitHub Actions).

# Example GitHub Actions workflow to run tests and deploy
name: CI/CD Pipeline
on: [push]
jobs:
  build-and-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Run Tests
        run: npm test
  deploy:
    needs: build-and-test
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to server
        run: ./deploy.sh
      

Using ChatOps with GitHub

ChatOps integrates chat platforms (like Slack) with GitHub for real-time collaboration and automation.

# Example: Use GitHub Actions to notify Slack on PR creation
name: Notify Slack on PR
on: pull_request
jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
      - uses: slackapi/slack-github-action@v1
        with:
          payload: '{"text":"New PR opened: ${{ github.event.pull_request.title }}"}'
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
      

Common Git Errors

Git errors often happen due to conflicts, detached HEAD, or missing commits. Understanding error messages helps fix them quickly.

<!-- Example: resolving "detached HEAD" state -->
git checkout main <!-- Switch back to main branch -->

<!-- Example: fixing merge conflicts manually -->
<!-- Edit conflicted files, then -->
git add <file>
git commit -m "Resolve merge conflict"
      

Network and Authentication Issues

Issues connecting to GitHub usually relate to SSH keys, tokens, or network settings.

<!-- Check SSH connection -->
ssh -T git@github.com

<!-- Refresh GitHub personal access token -->
<!-- Update remote URL with token if using HTTPS -->
git remote set-url origin https://<token>@github.com/<user>/<repo>.git
      

Resolving Sync Problems

Sync issues occur when local and remote branches diverge. Use pull, fetch, and rebase carefully.

<!-- Fetch latest changes -->
git fetch origin

<!-- Rebase local changes on top of origin/main -->
git rebase origin/main

<!-- Push rebased changes -->
git push origin main --force-with-lease
      

Debugging GitHub Actions

Use logs and verbose mode to debug GitHub workflows.

<!-- Enable debug logging in workflow -->
env:
  ACTIONS_STEP_DEBUG: true

<!-- Check detailed logs in GitHub Actions UI -->
      

Reporting Bugs and Getting Support

Report issues via GitHub Issues or official support channels, providing detailed logs and steps.

<!-- Open new issue on GitHub repo -->
<!-- Include reproduction steps and error messages -->
      

Using GitHub Status and Logs

Monitor GitHub's system status and review logs to diagnose service disruptions.

<!-- Visit https://www.githubstatus.com/ to check status -->

<!-- Use git log for local commit history review -->
git log --oneline --graph --decorate --all
      

Recent GitHub Features

GitHub has introduced new features like Discussions, GitHub Actions improvements, and Codespaces for cloud-based development.

        
        <!-- Discussions replace forums for Q&A inside repos -->

        
      

Upcoming Git Improvements

Git is evolving with features like partial clone improvements, sparse checkout enhancements, and performance optimizations.

        
        

        
        git clone --filter=blob:none git@github.com:user/repo.git
        git sparse-checkout init --cone
        git sparse-checkout set folder/subfolder
      

GitHub Copilot and AI Tools

GitHub Copilot uses AI to assist coding by suggesting whole lines or functions inside your IDE.

        

        
        

        
      

Cloud-Native Git Solutions

Cloud-native Git solutions like GitHub Codespaces and Gitpod enable instant development environments in the cloud.

        
        

        
      

GitHub Mobile and Desktop Apps

GitHub’s mobile and desktop apps improve workflow by allowing issue tracking, notifications, and repo management on the go.

        
        

        
      

Staying Updated with GitHub

Follow GitHub’s official blog, release notes, and community forums to keep up with the latest updates and features.

        
        
        

        
      

Creating Complex Workflows

GitHub Actions allows building multi-job workflows with dependencies and conditions to automate sophisticated CI/CD pipelines.

# Example: Workflow with multiple jobs and job dependencies
name: Complex CI Pipeline
on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3  # Check out repo code
      - name: Build project
        run: make build  # Run build command

  test:
    runs-on: ubuntu-latest
    needs: build  # Wait for build job to complete
    steps:
      - uses: actions/checkout@v3
      - name: Run tests
        run: make test  # Run tests

  deploy:
    runs-on: ubuntu-latest
    needs: test  # Wait for test job to succeed
    if: success()  # Only deploy if previous jobs succeeded
    steps:
      - name: Deploy to production
        run: ./deploy.sh  # Run deployment script
      

Reusable Workflows

Define reusable workflows that can be called by other workflows to avoid duplication and improve maintainability.

# Example: Call reusable workflow from another workflow
# In caller workflow:
jobs:
  call-workflow:
    uses: user/repo/.github/workflows/reusable.yml@main
    with:
      param1: value1
      param2: value2
      

Matrix Builds

Matrix strategy lets you run jobs with multiple configurations, like different OS or versions, in parallel.

# Example: Run tests on multiple Node.js versions
jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [12, 14, 16]
    steps:
      - uses: actions/checkout@v3
      - name: Setup Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm install
      - run: npm test
      

Secrets and Environment Variables

Securely store sensitive data in secrets and use environment variables to access them in workflows.

# Example: Use secret API key in a workflow
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Deploy using secret key
        env:
          API_KEY: ${{ secrets.API_KEY }}  # Use secret stored in repo settings
        run: ./deploy.sh --key $API_KEY
      

Workflow Triggers

Workflows can be triggered by various GitHub events, scheduled times, or manually.

# Example: Trigger workflow on push to main or on schedule
on:
  push:
    branches:
      - main
  schedule:
    - cron: '0 0 * * 0'  # Every Sunday at midnight
      

Setting Up a Personal Portfolio Repo

Create a repository to showcase your work and projects, including a README and project structure.

<!-- Initialize a new git repo -->
git init portfolio

<!-- Change directory to portfolio folder -->
cd portfolio

<!-- Create a README file -->
echo "# My Portfolio" > README.md

<!-- Add all files to staging -->
git add .

<!-- Commit the initial portfolio setup -->
git commit -m "Initial commit: add README"
      

Collaborative Team Project Example

Work with multiple team members by branching and merging changes collaboratively.

<!-- Create and switch to a new feature branch -->
git checkout -b feature-login

<!-- Make changes and stage them -->
git add login.html

<!-- Commit the changes -->
git commit -m "Add login page"

<!-- Push branch to remote -->
git push origin feature-login

<!-- Create pull request on GitHub to merge feature-login into main -->
      

Open Source Contribution Walkthrough

Fork a repo, clone it, make changes, and submit a pull request to contribute.

<!-- Fork the repository on GitHub UI -->

<!-- Clone your fork locally -->
git clone https://github.com/yourusername/project.git

<!-- Add upstream remote to original repo -->
git remote add upstream https://github.com/originalowner/project.git

<!-- Sync your fork with upstream -->
git fetch upstream
git checkout main
git merge upstream/main

<!-- Create a new branch for your changes -->
git checkout -b fix-typo

<!-- Commit your changes and push -->
git add .
git commit -m "Fix typo in README"
git push origin fix-typo

<!-- Open a pull request on GitHub -->
      

Automating a CI/CD Pipeline

Use GitHub Actions to automate tests and deployment on every push.

<!-- Example workflow file: .github/workflows/ci.yml -->
name: CI Pipeline

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '16'
      - name: Install dependencies
        run: npm install
      - name: Run tests
        run: npm test
      - name: Deploy
        if: success()
        run: echo "Deploying app..."
      <!-- Add your deploy script here -->
      <!-- See GitHub Actions docs for more details -->
      

Deploying a Website with GitHub Pages

Host static sites directly from your GitHub repo using GitHub Pages.

<!-- Create gh-pages branch -->
git checkout -b gh-pages

<!-- Add your website files -->
git add .

<!-- Commit and push to gh-pages branch -->
git commit -m "Deploy website to GitHub Pages"
git push origin gh-pages

<!-- Enable GitHub Pages in repo settings to serve from gh-pages branch -->
      

Maintaining a Large Codebase

Use branching strategies, code reviews, and automation to manage large projects effectively.

<!-- Use protected branches to prevent direct pushes to main -->

<!-- Require pull request reviews before merge -->

<!-- Automate testing and linting with CI workflows -->

<!-- Regularly update dependencies and refactor code -->
      

1. Introduction: Git & GitHub in AI Development

Overview of how version control is crucial for AI projects.

<!-- Initialize Git repo for AI project -->
git init ai-project      <!-- Start version control for your AI code and experiments -->

<!-- Add files to staging -->
git add .               <!-- Add all files including code, configs, notebooks -->

<!-- Commit initial project setup -->
git commit -m "Initial commit: AI project setup"
      
Output:
Initialized empty Git repository in /path/to/ai-project/.git/
[main (root-commit) abc1234] Initial commit: AI project setup
      

2. Managing AI Code and Data with Git

Best practices for handling AI source code and datasets in Git repos.

<!-- Use .gitignore to exclude large datasets -->
echo "data/" >> .gitignore  <!-- Ignore data folder from Git tracking -->

<!-- Track code files -->
git add src/ notebooks/

<!-- Commit changes -->
git commit -m "Add AI source code and notebooks"
      
Output:
[data/ added to .gitignore]
[main abc5678] Add AI source code and notebooks
      

3. Using Git Large File Storage (LFS) for AI Data

Managing large datasets and model files with Git LFS.

<!-- Install Git LFS -->
git lfs install

<!-- Track large files (e.g., model weights) -->
git lfs track "*.h5"
git lfs track "*.pt"

<!-- Add .gitattributes for LFS tracking -->
git add .gitattributes

<!-- Commit the LFS tracking setup -->
git commit -m "Configure Git LFS for large AI model files"
      
Output:
Git LFS initialized.
Tracking *.h5
Tracking *.pt
[main abc9012] Configure Git LFS for large AI model files
      

4. Branching Strategies for AI Experiments

How to organize branches for AI model training, testing, and production.

<!-- Create branch for new AI experiment -->
git checkout -b experiment-new-model

<!-- Work on experiment, then commit -->
git add model.py train.py
git commit -m "Add new model training code"

<!-- Merge experiment branch back to main when validated -->
git checkout main
git merge experiment-new-model
      
Output:
Switched to a new branch 'experiment-new-model'
[experiment-new-model abc3456] Add new model training code
Switched to branch 'main'
Merge made by the 'recursive' strategy.
      

5. Collaborating on AI Projects via GitHub

Using GitHub features to coordinate teams working on AI.

<!-- Push branch to remote repo -->
git push origin experiment-new-model

<!-- On GitHub: Open a Pull Request to merge branch -->
<!-- Team members review code and discuss changes -->
      
Output:
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 8 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (10/10), 1.5 KiB | 1.5 MiB/s, done.
Total 10 (delta 1), reused 0 (delta 0)
To https://github.com/user/ai-project.git
 * [new branch]      experiment-new-model -> experiment-new-model
      

6. Tracking AI Model Versions in GitHub

Versioning models and code together for reproducibility.

<!-- Tagging a model version -->
git tag -a v1.0 -m "Release model version 1.0"

<!-- Push tags to remote -->
git push origin v1.0
      
Output:
[main abc5678] Release model version 1.0
To https://github.com/user/ai-project.git
 * [new tag]         v1.0 -> v1.0
      

7. Using GitHub Issues for AI Project Management

Managing bugs, feature requests, and research tasks.

<!-- Create issue on GitHub UI -->
<!-- Example: "Improve data preprocessing pipeline" -->

<!-- Use labels, milestones, and assignees to organize tasks -->
      
Output:
Issue #12 created: Improve data preprocessing pipeline
Labels: enhancement, data
Assignee: @team-member
      

8. Automating AI Workflows with GitHub Actions

Setting up CI/CD pipelines for AI model training and deployment.

<!-- Example .github/workflows/ai-ci.yml -->
name: AI CI Pipeline

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.8'
      - name: Install dependencies
        run: pip install -r requirements.txt
      - name: Run tests
        run: pytest tests/
      - name: Deploy model
        if: success()
        run: python deploy.py
      <!-- Add your deployment script here -->
      
Output:
Run AI CI Pipeline
 - Checkout code
 - Setup Python 3.8
 - Install dependencies
 - Run tests
 - Deploy model if tests succeed
      

9. Integrating AI Model Testing in GitHub Pipelines

Automating unit tests and validation of AI models.

<!-- Use pytest to test AI model functions -->
def test_model_accuracy():
    assert model.evaluate() > 0.9  <!-- Ensure accuracy is above threshold -->

<!-- Add test step in GitHub Actions workflow -->
- name: Run AI model tests
  run: pytest tests/model_tests.py
      
Output:
============================= test session starts =============================
collected 3 items

test_model_accuracy.py ...                                             [100%]

============================== 3 passed in 0.12s ==============================
      

10. Managing Secrets and API Keys for AI Services

Securing AI credentials with GitHub Secrets.

<!-- Store secrets in GitHub repo settings >
<!-- Example: AI_API_KEY -->

<!-- Use secrets in GitHub Actions -->
- name: Use AI API Key
  run: python run_ai.py
  env:
    AI_API_KEY: ${{ secrets.AI_API_KEY }}
      
Output:
Using secret AI_API_KEY securely in CI workflow.
      

11. Using Pull Requests for AI Code Review

Collaborative review of AI code and experiments.

<!-- Push feature branch -->
git push origin feature-experiment

<!-- Open Pull Request on GitHub -->
<!-- Team reviews code and leaves comments -->

<!-- Address feedback by pushing commits -->
git add .
git commit -m "Fix issues raised in PR review"
git push origin feature-experiment
      
Output:
PR comments addressed, updated branch pushed.
      

12. Hosting AI Model Documentation on GitHub Pages

Creating docs and demos for AI projects.

<!-- Create docs folder and add markdown files -->

<!-- Push docs to gh-pages branch -->
git checkout -b gh-pages
git add docs/
git commit -m "Add AI model documentation"
git push origin gh-pages

<!-- Enable GitHub Pages to serve from gh-pages branch -->
      
Output:
Documentation published at https://username.github.io/ai-project
      

13. Leveraging GitHub Discussions for AI Community Collaboration

Facilitating communication and brainstorming.

<!-- Enable Discussions in GitHub repo settings -->

<!-- Use Discussions for brainstorming new features and research ideas -->
Output:
Community engagement through Discussions.

14. Using GitHub Packages to Distribute AI Models

Publishing models and dependencies via GitHub Packages.




pip install twine

twine upload --repository-url https://upload.pypi.org/legacy/ dist/*


pip install your-ai-model
Output:
Package uploaded and available for installation.
css Copy Edit

15. Real-World Example: Building and Deploying an AI Model with Git & GitHub

End-to-end walkthrough of versioning, collaborating, testing, and deploying an AI model using Git and GitHub.


git clone https://github.com/user/ai-project.git
cd ai-project


git checkout -b experiment-transformer



git add .
git commit -m "Add transformer model training"
git push origin experiment-transformer




git checkout main
git pull origin main


git tag -a v2.0 -m "Transformer model release"
git push origin v2.0


Output:
Repository cloned.
Branch created: experiment-transformer
Code committed and pushed.
Pull Request opened.
Release tagged v2.0.
CI pipeline deployed the model.

16. Monitoring AI Model Performance Over Time with Git

Track metrics, logs, and model outputs alongside code changes.

<!-- Commit new performance logs -->
git add logs/performance-2025-05-18.csv
git commit -m "Add latest model performance logs"
git push origin main
Output:
[main abc7890] Add latest model performance logs
To https://github.com/user/ai-project.git

17. Using GitHub Wiki for AI Project Documentation

Maintain rich documentation on AI algorithms, usage, and results.

<!-- Edit Wiki pages directly on GitHub UI -->
<!-- Add sections like 'Data Collection', 'Model Architecture', 'Training Details' -->
Output:
Wiki updated: Added training details section.

18. Integrating AI Experiment Tracking Tools with GitHub

Link tools like MLflow or Weights & Biases with GitHub for reproducibility.

<!-- Save experiment metadata in Git repo -->
git add experiments/exp_2025_05_18.json
git commit -m "Add MLflow experiment metadata"
git push origin main
Output:
[main abc8912] Add MLflow experiment metadata

19. Collaborative Model Development Using Forks and Pull Requests

How forks enable contributors to safely experiment and contribute.

<!-- Fork repo on GitHub -->
<!-- Clone fork locally -->
git clone https://github.com/contributor/ai-project.git

<!-- Make changes and push to fork -->
git push origin feature-update

<!-- Open Pull Request from fork to original repo -->
Output:
Feature branch pushed to fork.
Pull Request opened for review.

20. Using GitHub Templates for Issues and Pull Requests

Standardizing contributions and bug reports in AI projects.

<!-- Add ISSUE_TEMPLATE.md and PULL_REQUEST_TEMPLATE.md in .github folder -->
<!-- Example: Require experiment description and metrics for PRs -->
Output:
Templates added. Contributors must follow format.

21. Git Submodules for Managing AI Dependencies

Including external repos like datasets or shared utilities as submodules.

<!-- Add dataset repo as submodule -->
git submodule add https://github.com/data/dataset.git data/

<!-- Initialize and update submodules -->
git submodule update --init --recursive
Output:
Submodule 'data' added.

22. Handling Conflicts in AI Code Merges

Resolving merge conflicts when multiple contributors change the same files.

<!-- During merge, conflicts will appear -->
git merge feature-branch

<!-- Edit conflicted files to resolve issues -->
git add resolved-file.py
git commit -m "Resolve merge conflicts"
Output:
Merge conflict resolved.

23. Managing Data Versioning in Git with DVC

Using Data Version Control (DVC) for large data files alongside Git.

<!-- Initialize DVC in repo -->
dvc init

<!-- Track dataset -->
dvc add data/train.csv

<!-- Commit DVC files -->
git add data/train.csv.dvc .gitignore
git commit -m "Track train.csv with DVC"
Output:
Data file tracked by DVC.

24. Automating Model Retraining via GitHub Actions

Trigger model retraining pipelines on data updates.

<!-- Example trigger on data push -->
on:
  push:
    paths:
      - data/**

jobs:
  retrain:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Retrain model
        run: python retrain.py
Output:
Triggered retraining job on data update.

25. Reviewing AI Model Metrics in Pull Requests

Use GitHub checks to display test metrics before merging.

<!-- Use GitHub Actions to run tests and comment metrics on PR -->
- name: Run model tests
  run: pytest --metrics

<!-- Use action to post results as PR comment -->
Output:
PR comment: Model accuracy = 92%, Loss = 0.15

26. Managing Environment and Dependency Files

Version control of environment specs like requirements.txt or conda.yaml.

<!-- Add dependencies file -->
git add requirements.txt
git commit -m "Add dependencies list"
git push origin main
Output:
Dependencies file committed.

27. Using GitHub Codespaces for AI Development

Leverage cloud dev environments with pre-configured AI tools.

<!-- Open Codespace on GitHub UI -->
<!-- Develop AI models with zero local setup -->
Output:
Codespace environment ready.

28. Archiving Completed AI Experiments

Use Git tags and branches to archive finalized experiment states.

<!-- Tag experiment version -->
git tag -a exp-v1.1 -m "Finalized experiment 1.1"

<!-- Push tags -->
git push origin exp-v1.1
Output:
Experiment archived as tag exp-v1.1.

29. Using GitHub Projects to Manage AI Roadmaps

Track features, bugs, and releases in Kanban boards.

<!-- Create Project Board on GitHub -->
<!-- Add cards for AI features and tasks -->
Output:
Project board created and updated.

30. Best Practices for Git & GitHub in AI Development

Summary of workflows: small commits, meaningful messages, branches for features, code reviews, and CI/CD.

<!-- Example commit message -->
git commit -m "Refactor data loader for efficiency"

<!-- Push regularly and request reviews -->
git push origin feature-branch
Output:
Commit pushed, ready for review.

31. Managing Model Checkpoints with Git

Store and version intermediate model checkpoints for easy rollback and analysis.

<!-- Save checkpoint files -->
git add checkpoints/model_epoch_10.pth
git commit -m "Add checkpoint after epoch 10"
git push origin main
Output:
[main abc1234] Add checkpoint after epoch 10

32. Using GitHub Secrets to Secure AI API Keys

Store sensitive credentials safely for use in CI/CD workflows.

<!-- Add secret in GitHub repo settings -->
<!-- Use secret in GitHub Actions workflow -->
env:
  API_KEY: ${{ secrets.AI_API_KEY }}
Output:
Secret API key used securely in workflow.

33. Integrating GitHub with AI Experiment Tracking Dashboards

Link GitHub commits and PRs to experiment dashboards for traceability.

<!-- Include commit hash in experiment metadata -->
commit_id = os.getenv('GITHUB_SHA')

<!-- Push metadata to dashboard API -->
Output:
Experiment linked with commit abc1234.

34. Automating Data Validation in GitHub Actions

Run scripts to validate data quality before merging new data changes.

<!-- Example GitHub Action step -->
- name: Validate data files
  run: python validate_data.py data/new_data.csv
Output:
Data validation passed successfully.

35. Versioning AI Model Hyperparameters with Git

Keep track of hyperparameter config files alongside code changes.

<!-- Commit hyperparameter JSON or YAML -->
git add configs/hparams.yaml
git commit -m "Update hyperparameters for model v2"
git push origin main
Output:
[main abc5678] Update hyperparameters for model v2

36. Using Pull Request Templates for AI Experiment Submissions

Ensure contributors provide necessary experiment details before review.

<!-- Add PULL_REQUEST_TEMPLATE.md -->
<!-- Include sections for experiment setup, results, and code changes -->
Output:
PR template enforced for consistent experiment info.

37. Utilizing GitHub Discussions to Brainstorm AI Ideas

Collaborate asynchronously on research questions and project directions.

<!-- Create discussion categories for AI topics -->
<!-- Use markdown formatting to organize discussions -->
Output:
Active discussions fostering collaboration.

38. Using GitHub Actions for Continuous Model Evaluation

Set up workflows to regularly evaluate models on test data and report results.

<!-- Schedule workflow to run tests nightly -->
on:
  schedule:
    - cron: "0 0 * * *"

jobs:
  evaluate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Run evaluation
        run: python evaluate.py
Output:
Model evaluation completed; results posted.

39. Managing AI Dataset Licenses and Compliance with Git

Track licensing info and compliance documents within the repo.

<!-- Add LICENSE and compliance.txt files -->
git add LICENSE compliance.txt
git commit -m "Add dataset license and compliance info"
git push origin main
Output:
License and compliance documents committed.

40. Migrating AI Projects to Monorepos Using Git

Consolidate multiple AI projects and microservices into one repo.

<!-- Move projects into subdirectories -->
mkdir -p ai-projects/model-training
mkdir -p ai-projects/data-pipelines

git add ai-projects/
git commit -m "Migrate projects into monorepo structure"
git push origin main
Output:
Monorepo structure committed.