Skip to main content
In this lesson we cover Git — the distributed version control system used to track source code, configuration files, playbooks, and more. Whether you’re a developer, system administrator, support engineer, or project manager, basic Git skills are essential for downloading code, managing changes, and collaborating with others. What we’ll cover
  • What Git does and why it matters.
  • How to install Git and verify the installation.
  • Creating and working with repositories (local and remote).
  • How to stage, commit, and inspect changes.
  • Common workflows and next steps (clone, push, pull) and the difference between Git and hosting services like GitHub.
This article focuses on the essentials so you can quickly download code, make local changes, and share them to a remote repository. Git can be deep — consider this a practical starting point. What problem does Git solve? Imagine a small Flask app with a handful of files (LICENSE, README.md, requirements.txt, main.py). With only occasional edits you might remember your changes. As the project grows or multiple people contribute, you need a way to:
  • Track what changed, when, and who changed it.
  • Let multiple developers work simultaneously without overwriting each other.
  • Create named snapshots (versions) of the project at important milestones.
Git addresses these needs by tracking changes to files and providing tools to create commits, branch, merge, and synchronize with remote repositories. High-level Git workflow
  1. Initialize a Git repository in your project directory (git init) or clone an existing remote repository (git clone).
  2. Choose which files Git should track (use .gitignore to exclude files).
  3. Stage a coherent set of changes into the index using git add.
  4. Create a commit (git commit) to record a snapshot.
  5. Repeat: edit → stage → commit; push and pull to synchronize with remote repositories when collaborating.
A few important points
  • Git does not auto-version on save. You explicitly create versions with git add + git commit.
  • Stage only the changes you intend to include in a commit to keep history focused.
  • The working directory, staging area (index), and the commit history are the main Git states to understand.
Concise textual summary
  • Working directory: your files.
  • .git directory: repository metadata created by git init.
  • Staging area (index): git add selects what goes into the next commit.
  • Commit: git commit records the staged snapshot as a new version.
A diagram explaining the Git workflow, showing a repository file tree (LICENSE, README.md, main.py, utils.py, etc.) and columns for Version 1/2/3 plus a Staging area highlighting staged files. On the right are numbered steps like initialize a Git repository, configure files to track, stage changes, and commit changes.
Getting started: commands and examples
  1. Install Git
  • On CentOS/RHEL:
Verify the installation:
  1. Initialize a repository To start tracking an existing project directory:
This creates a hidden .git directory that contains all repository metadata and history.
  1. Check repository status Before adding files, check what Git sees:
  1. Decide which files to track You can add each file explicitly:
Or add everything and use a .gitignore to exclude personal or generated files such as notes.txt. .gitignore is the standard way to exclude files from being tracked. After staging, verify:
  1. Modify files and stage specific changes When you edit a tracked file (e.g., main.py) Git marks it as modified:
Stage the modified file:
You can also stage only parts of a file (git add -p) when you want finer-grained commits.
  1. Commit changes Create a commit from staged changes and include a descriptive message:
Write commit messages that clearly describe what changed and why. Small, focused commits with meaningful messages make history easier to read, review, and revert if needed.
How git add behaves
  • Untracked files: git add <file> both starts tracking and stages the file.
  • Tracked and modified files: git add <file> stages the current changes for the next commit.
  • Partial staging: use git add -p to interactively choose hunks to stage.
Quick reference table Summary and next steps
  • Core local workflow: git init → git add → git commit.
  • Use git status often to understand repository state.
  • Practice creating commits, making targeted changes, and using .gitignore to exclude local files.
  • Next topics to learn: cloning remote repositories (git clone), connecting to remotes (git remote add), pushing and pulling (git push, git pull), branching and merging, and collaboration workflows (forks, pull requests).
Useful references That’s the end of this introduction. Practice these steps hands-on to become comfortable; remote collaboration (clone, push, pull, branching) is the natural next step.

Watch Video

Practice Lab