Hands-on practice with fundamental Git operations
Hands-on exercises to practice basic Git operations and reinforce your understanding.
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.
You're starting a new project called "recipe-collection". Create a Git repository and set it up with proper configuration.
- 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
README.md
$ git add README.md $ git commit -m "Initial commit: Add README"`} />
- Directory contains a .git folder
Git configuration shows correct user info
Repository has at least one commit
Add three recipe files to your collection and practice the basic Git workflow of
staging and committing changes.
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
chocolate-cake.md
$ echo "# Pasta Carbonara Recipe" > carbonara.md $ echo "# Garden Salad Recipe" > garden-salad.md
$ 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"
$ git log --oneline`} />
Configure your repository to ignore certain files and directories commonly excluded in recipe management systems.
- Ignore all image files in a future 'images' directory
- Ignore temporary files ending with .tmp
- Ignore a local notes directory
- Ignore OS-specific files
- 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