Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
What is Git
📖 Scenario: You are starting a new project and want to keep track of your changes safely. Git helps you save different versions of your work so you can go back if needed.
🎯 Goal: Learn the basics of Git by creating a new Git repository, adding a file, and committing the changes.
📋 What You'll Learn
Create a new Git repository
Add a file to the repository
Commit the file with a message
Check the commit history
💡 Why This Matters
🌍 Real World
Developers use Git to keep track of changes in their code projects, so they never lose work and can collaborate easily.
💼 Career
Knowing Git is essential for software development jobs, as it is the most popular tool for version control and teamwork.
Progress0 / 4 steps
1
Initialize a Git repository
Type git init in your project folder to create a new Git repository.
Git
Hint
Use git init to start tracking your project with Git.
2
Create a file and add it to Git
Create a file named README.md with some text and then type git add README.md to add it to Git.
Git
Hint
Use echo "text" > README.md to create the file and git add README.md to stage it.
3
Commit the changes
Type git commit -m "Initial commit" to save your changes with a message.
Git
Hint
Use git commit -m "message" to save your staged changes with a note.
4
View the commit history
Type git log to see the list of commits you have made.
Git
Hint
Use git log to check your commit history and see your saved changes.
Practice
(1/5)
1. What is the main purpose of Git?
easy
A. To create websites from scratch
B. To edit images and videos
C. To save and track changes in files over time
D. To manage computer hardware settings
Solution
Step 1: Understand Git's role
Git is a tool designed to save and track changes in files, especially code files.
Step 2: Compare options
Options B, C, and D describe tasks unrelated to Git's main function.
Final Answer:
To save and track changes in files over time -> Option C
Quick Check:
Git = tracks file changes [OK]
Hint: Git tracks file changes, not edits or hardware [OK]
Common Mistakes:
Confusing Git with editing software
Thinking Git manages hardware
Believing Git builds websites
2. Which of the following is the correct command to start a new Git repository?
easy
A. git start
B. git init
C. git create
D. git begin
Solution
Step 1: Recall Git commands
The command to create a new Git repository is git init.
Step 2: Check other options
Commands like git start, git create, and git begin do not exist in Git.
Final Answer:
git init -> Option B
Quick Check:
Initialize repo = git init [OK]
Hint: Use 'git init' to start a repo, others are invalid [OK]
Common Mistakes:
Using 'git start' instead of 'git init'
Confusing command names
Trying commands that don't exist
3. What will be the output of the command git status right after running git init in a new folder?
medium
A. No commits yet, nothing to commit, working tree clean
B. Error: repository not found
C. All files are staged for commit
D. Untracked files present, please add them
Solution
Step 1: Understand 'git init' effect
Running git init creates an empty Git repository with no commits.
Step 2: Check 'git status' output
Right after init, git status shows "No commits yet" and "working tree clean" because no files are added or changed.
Final Answer:
No commits yet, nothing to commit, working tree clean -> Option A
Quick Check:
git status after init = no commits, clean [OK]
Hint: After init, status shows no commits and clean tree [OK]