The Syntax Diaries

Practical code notes, tools & guided learning for developers.

BlogToolsTutorialsAboutContact
PrivacyTermsCookiesAdmin

© 2026 The Syntax Diaries

100% private · no tracking · works offline100% client-side/no data leaves your browser/no accounts/works offline

The Syntax Diaries
BlogToolsTutorialsAbout
build log live
Tutorial / Git
Practice45 minutesbeginner

Basic Operations Exercises

Hands-on practice with fundamental Git operations

§ On this page

Learning ObjectivesPractice OverviewExercise 1: Repository SetupScenarioSteps:Solution:Validation Checklist:Exercise 2: Basic WorkflowScenarioSteps:Sample Solution:Exercise 3: .gitignore ConfigurationScenarioRequirements:Solution:Test Your Configuration:Practice Tips

Basic Operations Exercises#

Hands-on exercises to practice basic Git operations and reinforce your understanding.

Learning Objectives#

  • Apply your knowledge of Git repository initialization and configuration
  • Practice the basic Git workflow with real-world scenarios
  • Master file staging and commit operations
  • Implement effective .gitignore patterns for different project types

Practice Overview#

Welcome to the practical exercises for basic Git operations. These exercises will help reinforce your understanding of fundamental Git concepts through hands-on practice. Each exercise includes step-by-step instructions and validation criteria to ensure you're on the right track.

Exercise 1: Repository Setup#

Scenario#

You're starting a new project called "recipe-collection". Create a Git repository and set it up with proper configuration.

Steps:#

            - Create a new directory called "recipe-collection"
            - Initialize it as a Git repository
            - Configure your name and email for this repository
            - Create a README.md file with a project description
            - Make your first commit

Solution:#

           README.md

Make first commit#

$ git add README.md $ git commit -m "Initial commit: Add README"`} />

Validation Checklist:#

            - Directory contains a .git folder

              Git configuration shows correct user info

              Repository has at least one commit

Exercise 2: Basic Workflow#

Scenario#

          Add three recipe files to your collection and practice the basic Git workflow of
          staging and committing changes.

Steps:#

            Create three .md files for different recipes
            - Stage the files individually
            - Check status between operations
            - Make meaningful commits for each recipe
            - Review your commit history

Sample Solution:#

           chocolate-cake.md

$ echo "# Pasta Carbonara Recipe" > carbonara.md $ echo "# Garden Salad Recipe" > garden-salad.md

Stage and commit files individually#

$ git add chocolate-cake.md $ git commit -m "Add chocolate cake recipe"

$ git add carbonara.md $ git commit -m "Add pasta carbonara recipe"

$ git add garden-salad.md $ git commit -m "Add garden salad recipe"

Check history#

$ git log --oneline`} />

Exercise 3: .gitignore Configuration#

Scenario#

Configure your repository to ignore certain files and directories commonly excluded in recipe management systems.

Requirements:#

            - Ignore all image files in a future 'images' directory
            - Ignore temporary files ending with .tmp
            - Ignore a local notes directory
            - Ignore OS-specific files

Solution:#

Test Your Configuration:#

Practice Tips#

          - Use

                git status

              frequently to monitor your repository's state
          - Write clear, descriptive commit messages that explain what changes were made
          - If you make a mistake, don't worry! Use

                git log

              and

                git reset

              to recover

Previous

Debugging with Git

Next

Branching Exercises