0
0
Intro to Computingfundamentals~20 mins

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

Choose your learning style9 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.