Skip to main content
Learn how to use Git for version control by walking through a simple mock project. We’ll cover:
  • Initializing a Git repository
  • Staging and committing files
  • Inspecting commit history
By the end of this guide, you’ll understand the core Git commands for day-to-day workflows.

Table of Contents

  1. Initialize a Git Repository
  2. Stage and Commit greetings.txt
  3. Add and Commit bye.txt
  4. Quick Reference: Common Git Commands
  5. Links and References

1. Initialize a Git Repository

Start by creating a new directory and turning it into a Git repository:
You should see:
Now you’re inside a Git-controlled project. All subsequent Git commands will operate here.

2. Stage and Commit greetings.txt

First, create a file named greetings.txt:
The image shows a GNU Nano text editor screen with a new file named "greetings.txt" open. The screen displays various command options at the bottom.
Check the repository status to see untracked files:
Sample output:
Stage and commit your changes:
View the commit history:
Sample output:
A clear, descriptive commit message helps you and your team understand the purpose of each change.

3. Add and Commit bye.txt

Repeat the workflow to add a second file:
  1. Create bye.txt:
  2. Confirm it’s untracked:
  3. Stage all changes at once:
  4. Commit with a message:
  5. Review the full commit history:
You’ll see both commits listed, with the most recent on top.
Always run git status before committing to avoid accidentally omitting or including unwanted files.

Quick Reference: Common Git Commands


Start practicing these commands today to build a solid foundation in version control!

Watch Video