Module 4: Version control with Git
Module quiz: Version control with Git
Graded Assignment
1. Which of the following is a benefit of using version control? Select all that apply.
- Enables collaboration among multiple developers. ✅
- Tracks changes and maintains a history of the project. ✅
- Helps merge code changes and highlights potential conflicts.
- Organizes project versions and changes for better tracking.
Explanation:
Enables collaboration among multiple developers: Version control allows multiple developers to work on the same project simultaneously, making collaboration easy.
Tracks changes and maintains a history of the project: It records changes to the code, helping you track progress and revert to previous versions when needed.
2. What is the purpose of git init?
- It creates a local copy of a repository from GitHub.
- It sets up a new branch within the repository.
- It pushes your changes to GitHub.
- It initializes a new Git repository in your current directory. ✅
Explanation:
The git init
command creates a new Git repository in the current directory, enabling version control for the project.
3. Which of the following commands is used to verify if Git is installed correctly?
- git install
- git verify
- git status
- git –version ✅
Explanation:
Running git --version
displays the installed Git version, confirming that Git is installed on your system.
4. What is the first step in setting up a GitHub account?
- Create a new GitHub repository.
- Create a username and password on GitHub. ✅
- Add an SSH key to your GitHub account.
- Configure Git to recognize your GitHub account.
Explanation:
The first step in setting up a GitHub account is to create an account by selecting a username and password. Configuring Git or adding SSH keys happens after the account is created.
5. What is the purpose of git commit?
- It creates a snapshot of your changes and stores them in the Git history. ✅
- It stages files for tracking in the repository.
- It deletes untracked files.
- It syncs your changes with a remote repository.
Explanation:
The git commit
command takes a snapshot of the changes in the staging area and saves it to the repository’s history, along with a descriptive message.
6. What happens when you run git push origin main?
- It pushes changes from the local main branch to the remote repository. ✅
- It updates your local main branch with changes from the remote repository.
- It deletes the local main branch after syncing with the remote repository.
- It initializes a new main branch in the remote repository if it doesn’t already exist.
Explanation:
The git push origin main
command uploads the commits from your local main
branch to the main
branch of the remote repository.
7. Which command would you use to create a new Git repository in your project folder?
- git initialize
- git init ✅
- git repo create
- git init project_folder
Explanation:
The git init
command initializes a new Git repository in the current project folder, setting it up for version control.
8. Which of the following is a correct Gitflow workflow for creating a feature?
- Create a feature branch from develop, make changes, then merge it back into develop. ✅
- Create a feature branch from master, make changes, then merge it back into develop.
- Create a feature branch from develop, test the changes, and merge directly into master.
- Create a feature branch from develop, integrate changes into master, and continue development.
Explanation:
In the Gitflow workflow, feature branches are created from the develop
branch. After completing the feature, the branch is merged back into develop
to prepare for integration or testing.
9. True or False: Git can be used to manage and version control files other than code.
- False
- True ✅
Explanation:
Git can manage and version control any type of files, including documents, images, and configurations, although it is commonly used for code.
10. Which of the following commands can NOT be used to update your local repository from a remote repository
- git clone
- git update
- git fetch
- git pull