Git Tutorials


Git Tutorials Roadmap


Section 1: Introduction to Version Control and Git Basics

  • What is Version Control?
    • Understanding the need for version control (tracking changes, collaboration, backup).
    • Centralized vs. Distributed Version Control Systems (VCS).
  • What is Git?
    • Git as a distributed VCS.
    • Key concepts: repository, commit, snapshot, branch, merge.
  • Setting up Git:
    • Installing Git on your operating system (Windows, macOS, Linux).
    • Configuring Git with your name and email (git config).
  • Creating and Cloning Repositories:
    • Initializing a new Git repository (git init).
    • Cloning an existing remote repository (git clone).
  • The Git Workflow (Add, Commit):
    • Understanding the working directory, staging area (index), and Git repository.
    • Adding changes to the staging area (git add).
    • Committing changes to the repository (git commit).
    • Writing good commit messages.
  • Checking the Status and History:
    • Checking the status of your working directory (git status).
    • Viewing the commit history (git log).
    • Understanding commit hashes.

Section 2: Working with Changes and Undoing Things

  • Viewing Differences:
    • Viewing changes before staging (git diff).
    • Viewing changes between the staging area and the last commit (git diff --staged).
  • Undoing Changes:
    • Unstaging changes (git reset HEAD or git restore --staged ).
    • Discarding changes in the working directory (git checkout -- or git restore ).
    • Amending the last commit (git commit --amend).
  • Ignoring Files:
    • Creating a .gitignore file to exclude files from being tracked.
    • Understanding common patterns for .gitignore.

Section 3: Branching and Merging

  • Understanding Branches:
    • What is a branch? Why are branches important?
    • The default branch (usually main or master).
  • Creating and Switching Branches:
    • Creating a new branch (git branch ).
    • Switching to a branch (git checkout or git switch ).
    • Creating and switching in one command (git checkout -b or git switch -c ).
  • Merging Branches:
    • Understanding the merge process.
    • Merging one branch into another (git merge ).
    • Resolving merge conflicts.
  • Managing Branches:
    • Listing branches (git branch).
    • Deleting branches (git branch -d ).

Section 4: Working with Remote Repositories

  • Understanding Remote Repositories:
    • What is a remote repository (e.g., on GitHub, GitLab, Bitbucket)?
    • Adding a remote (git remote add origin ).
    • Viewing remotes (git remote -v).
  • Pushing and Pulling Changes:
    • Pushing local commits to a remote repository (git push).
    • Fetching changes from a remote repository (git fetch).
    • Pulling changes from a remote repository (git pull - fetch and merge).
  • Cloning Remote Repositories:
    • Revisiting git clone and its role with remotes.

Section 5: Collaboration and Workflows

  • Basic Collaboration Workflow:
    • Cloning, making changes, committing, pulling, pushing.
  • Handling Conflicts When Pulling:
    • Resolving merge conflicts that occur during a git pull.
  • Introduction to Forking and Pull Requests (on platforms like GitHub):
    • Understanding the concept of forking a repository.
    • Creating a pull request to propose changes.
    • Reviewing and merging pull requests.

Section 6: Advanced Git Concepts (Optional, for later)

  • Rebasing:
    • Understanding rebasing as an alternative to merging.
    • Interactive rebasing for cleaning up commit history.
    • Caution: Rebasing public history can be problematic.
  • Stashing Changes:
    • Temporarily saving changes without committing them (git stash).
    • Applying stashed changes (git stash apply, git stash pop).
  • Tagging:
    • Creating lightweight and annotated tags for marking releases or important points in history (git tag).
  • Cherry-Picking Commits:
    • Applying a single commit from one branch to another (git cherry-pick).
  • Bisecting:
    • Using git bisect to find the commit that introduced a bug.

Section 7: Git Tools and GUI Clients (Optional)

  • Exploring Git Command Line Interface (CLI) further.
  • Introduction to Git GUI Clients:
    • Visualizing history and managing repositories with GUI tools (e.g., GitKraken, Sourcetree, VS Code Git integration).

Section 8: Best Practices and Tips

  • Writing Meaningful Commit Messages.
  • Committing Frequently and Early.
  • Keeping Branches Small and Focused.
  • Understanding Git Hooks (Advanced).