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?
Think about how you would keep track of changes in a shared document.
Git is a tool that records every change made to files, allowing you to review, compare, or revert to earlier versions. It does not create content or delete history automatically.
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?
Think about what happens after you modify a file but before you add it again.
After the first commit, the file is changed by adding 'World' but not staged. git status shows the file as modified but unstaged.
You want to start working on a new feature without affecting the main code. Which Git command creates a new branch called feature?
Creating a branch is different from switching or merging branches.
git branch feature creates a new branch named feature. Other options either switch branches, merge, or are invalid.
git pull and git fetchWhich statement correctly describes the difference between git pull and git fetch?
Think about which command updates your local files immediately.
git pull downloads and merges remote changes into your current branch automatically. git fetch only downloads changes and requires manual merging.
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'
Consider what git reset --soft HEAD~1 does to the last commit.
git reset --soft HEAD~1 moves HEAD back one commit but keeps changes staged. The next commit replaces the previous last commit. So the log shows 'Commit A' and 'Commit C'.