Bird
Raised Fist0
Intro to Computingfundamentals~20 mins

Version control concept (Git) in Intro to Computing - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Git Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the main purpose of Git in software development?

Imagine you and your friends are writing a story together. You want to keep track of every change each person makes so you can go back if needed. What role does Git play in this situation?

AGit deletes old versions of the story to save space.
BGit automatically writes new parts of the story for you.
CGit helps keep a history of all changes so you can review or undo them.
DGit sends your story to a printer.
Attempts:
2 left
💡 Hint

Think about how you would keep track of changes in a shared document.

❓ trace
intermediate
2:00remaining
Trace the sequence of Git commands and their effect

Consider this sequence of Git commands run in a new project folder:

git init
echo 'Hello' > file.txt
git add file.txt
git commit -m 'Add greeting'
echo 'World' >> file.txt
git status

What will git status show?

AIt shows that <code>file.txt</code> is modified and not staged for commit.
BIt shows no changes; the working directory is clean.
CIt shows <code>file.txt</code> is staged for commit.
DIt shows an error because <code>file.txt</code> was not added.
Attempts:
2 left
💡 Hint

Think about what happens after you modify a file but before you add it again.

❓ identification
advanced
2:00remaining
Identify the Git command that creates a new branch

You want to start working on a new feature without affecting the main code. Which Git command creates a new branch called feature?

Agit checkout main
Bgit merge feature
Cgit commit -b feature
Dgit branch feature
Attempts:
2 left
💡 Hint

Creating a branch is different from switching or merging branches.

❓ Comparison
advanced
2:00remaining
Compare the difference between git pull and git fetch

Which statement correctly describes the difference between git pull and git fetch?

A<code>git pull</code> only downloads changes; <code>git fetch</code> downloads and merges changes.
B<code>git pull</code> downloads changes and merges them automatically; <code>git fetch</code> only downloads changes without merging.
C<code>git fetch</code> deletes remote branches; <code>git pull</code> creates new branches.
D<code>git fetch</code> uploads your changes to the remote repository; <code>git pull</code> downloads changes.
Attempts:
2 left
💡 Hint

Think about which command updates your local files immediately.

🚀 Application
expert
3:00remaining
What is the output of this Git log command sequence?

Given this sequence of commands and their effects, what will git log --oneline show?

git init
 echo 'A' > file.txt
 git add file.txt
 git commit -m 'Commit A'
 echo 'B' >> file.txt
 git commit -am 'Commit B'
 git reset --soft HEAD~1
 git commit -m 'Commit C'
ATwo commits: 'Commit A' and 'Commit C', with 'Commit B' replaced by 'Commit C'.
BThree commits: 'Commit A', 'Commit B', and 'Commit C'.
COne commit: 'Commit C' only.
DError because <code>git reset --soft</code> requires a branch name.
Attempts:
2 left
💡 Hint

Consider what git reset --soft HEAD~1 does to the last commit.

Practice

(1/5)
1. What is the main purpose of using version control systems like Git?
easy
A. To speed up the computer's processor
B. To create graphics and animations
C. To delete old files automatically
D. To save and track changes to files over time

Solution

  1. Step 1: Understand version control basics

    Version control systems keep a history of changes made to files, allowing users to track and manage edits.
  2. Step 2: Compare options to purpose

    Only To save and track changes to files over time describes saving and tracking changes, which matches the main purpose of Git.
  3. Final Answer:

    To save and track changes to files over time -> Option D
  4. Quick Check:

    Version control = save and track changes [OK]
Hint: Version control = saving drafts of your work [OK]
Common Mistakes:
  • Confusing version control with speeding up hardware
  • Thinking it deletes files automatically
  • Assuming it creates graphics
2. Which Git command is used to start a new repository in your project folder?
easy
A. git init
B. git commit
C. git add
D. git push

Solution

  1. Step 1: Identify command purpose

    git init creates a new Git repository in the current folder, starting version control.
  2. Step 2: Check other commands

    git add stages files, git commit saves changes, and git push sends changes to a remote repository.
  3. Final Answer:

    git init -> Option A
  4. Quick Check:

    Start repo = git init [OK]
Hint: Initialize repo with git init command [OK]
Common Mistakes:
  • Using git add to start a repo
  • Confusing git commit with git init
  • Thinking git push starts a repo
3. What will happen after running these commands in order?
git init
git add file.txt
git commit -m "First commit"
medium
A. file.txt is ignored by Git
B. A new repository is created and file.txt is saved in the first commit
C. The repository is deleted
D. file.txt is deleted from the folder

Solution

  1. Step 1: Analyze each command

    git init creates a new repo, git add file.txt stages the file, and git commit saves the staged file as a commit.
  2. Step 2: Understand the result

    The file is saved in the repository history as the first commit; nothing is deleted or ignored.
  3. Final Answer:

    A new repository is created and file.txt is saved in the first commit -> Option B
  4. Quick Check:

    Init + add + commit = save file in repo [OK]
Hint: Init, add, commit = save file snapshot [OK]
Common Mistakes:
  • Thinking commit deletes files
  • Confusing add with delete
  • Assuming file is ignored automatically
4. You ran git commit -m "Update" but got an error saying "nothing to commit". What is the likely cause?
medium
A. You did not stage any files with git add
B. You forgot to run git init
C. You typed the commit message incorrectly
D. Your files are deleted

Solution

  1. Step 1: Understand the error message

    "Nothing to commit" means Git sees no changes staged to save.
  2. Step 2: Identify missing step

    Before committing, files must be staged with git add. Without staging, commit has nothing to save.
  3. Final Answer:

    You did not stage any files with git add -> Option A
  4. Quick Check:

    Commit needs staged files [OK]
Hint: Stage files with git add before commit [OK]
Common Mistakes:
  • Skipping git add before commit
  • Assuming commit message typo causes this error
  • Thinking files are deleted
5. You want to save changes to two files, index.html and style.css, but only index.html should be included in the commit. Which sequence of commands achieves this?
hard
A. git commit -m "Update index"
B. git add . git commit -m "Update index"
C. git add index.html git commit -m "Update index"
D. git add style.css git commit -m "Update index"

Solution

  1. Step 1: Stage only the desired file

    Using git add index.html stages only that file, excluding others.
  2. Step 2: Commit staged changes

    git commit -m "Update index" saves only the staged index.html changes.
  3. Final Answer:

    git add index.html git commit -m "Update index" -> Option C
  4. Quick Check:

    Stage specific file, then commit [OK]
Hint: Add only files you want before commit [OK]
Common Mistakes:
  • Using git add . to stage all files
  • Committing without staging
  • Adding wrong file by mistake
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard