Get Introduction to Git and GitHub Coursera Quiz Answers of All Modules
Table of Contents
Introduction to Git and GitHub Module 01 Quiz Answers
Before Version Control Practice Quiz Answers
Q1. Your colleague sent you a patch called fix_names.patch, which fixes a config file called fix_names.conf. What command do you need to run to apply the patch to the config file?
- diff names.conf fix_names.conf
- patch fix_names.conf names.conf
- patch fix_names.conf < fix_names.patch
- diff names.conf_orig names.conf_fixed > fix_names.conf
Explanation: To apply a patch, you use the patch
command followed by the file that needs to be patched (fix_names.conf
) and the patch file (fix_names.patch
). The correct syntax is patch fix_names.conf < fix_names.patch
.
Q2. You’re helping a friend with a bug in a script called fix_permissions.py, which fixes the permissions of a bunch of files. To work on the file, you make a copy and call it fix_permissions_modified.py. What command do you need to run after solving the bug to send the patch to your friend?
- diff fix_permissions.py fix_permissions_modified.py > fix_permissions.patch
- patch fix_permissions.py < fix_permissions_modified.py
- patch fix_permissions.py > fix_permissions.patch
- diff fix_permissions.py fix_permissions.diff
Explanation: To create a patch file that contains the differences between the original file and the modified file, you use the diff
command. The syntax is diff fix_permissions.py fix_permissions_modified.py > fix_permissions.patch
.
Q3. The _ command highlights the words that changed in a file instead of working line by line.
- diff
- diff -u
- vimdiff
- patch
Explanation: wdiff
is a command that highlights the word-level changes between two files, instead of showing line-by-line differences as diff
does.
Q4. How can we choose the return value our script returns when it finishes?
- Using the exit command from the sys module
- Use the patch command
- Use the diff command
- Use meld
Explanation: In Python, you can use the sys.exit()
function to specify the return value (exit status) of the script. A return value of 0 typically indicates success, while non-zero values indicate errors.
Q5. In addition to the original files, what else do we need before we can use the patch command?
- Diff file
- exit command of the sys module
- Version control
- Full copy of the new files
Explanation: Before using the patch
command, you need a diff file that contains the differences between the original file and the modified file. This is what the patch
command applies to the original file to update it.
Version Control Systems Practice Quiz Answers
Q1. How can a VCS (Version Control System) come in handy when updating your software, even if you’re a solo programmer? Check all that apply.
- Git retains local copies of repositories, resulting in fast operations.
- If something breaks due to a change, you can fix the problem by reverting to a working version before the change.
- Git relies on a centralized server.
- Git allows you to review the history of your project.
Explanation: Version control systems like Git help solo programmers by enabling them to manage changes efficiently. You can quickly revert to a stable version if something breaks and review your project’s history. Git does not rely on a centralized server because it is a distributed VCS.
Q2. Who is the original creator and main developer of the VCS (Version Control System) tool Git?
- Bill Gates
- Guido van Rossum
- Linus Torvalds
- James Gosling
Explanation: Linus Torvalds, the creator of Linux, developed Git to support the development of the Linux kernel. Git is a distributed version control system that he designed to address limitations in existing systems.
Q3. _ is a feature of a software management system that records changes to a file or set of files over time so that you can recall specific versions later.
- A repository
- sys.exit()
- Version control
- IDE
Explanation: Version control is the system that tracks changes to files over time, allowing you to recall specific versions later. This is fundamental to systems like Git.
Q4. A _ is a collection of edits that have been submitted to the version control system for safekeeping.
- IDE
- version control system
- commit
- repository
Explanation: A commit is a snapshot of changes that have been added to a version control system. It captures a collection of edits and stores them for later reference.
Q5. Within a VCS, project files are organized in centralized locations called _ where they can be called upon later.
- commits
- repositories
- IDE
- yum
Explanation: In a version control system, a repository is a centralized location where project files and their history are stored. It is where the project files live and can be retrieved from later.
Using Git Practice Quiz Answers
Q1. Before changes in new files can be added to the Git directory, what command will tell Git to track our file in the list of changes to be committed?
- git status
- git add
- git commit
- git init
Explanation: The git add
command tells Git to track changes in a file and prepares it to be committed. It adds the file to the staging area before committing.
Q2. Which command would we use to review the commit history for our project?
- git clone
- git status
- git config -l
- git log
Explanation: The git log
command shows the commit history of the project, displaying past commits, authors, dates, and commit messages.
Q3. What command would we use to make Git track our file?
- git clone
- git status
- git add
- git log
Explanation: To make Git track a file, you use the git add
command. This stages the file for the next commit.
Q4. Which command would we use to look at our config?
- git clone
- git status
- git config -l
- git log
Explanation: The git config -l
command displays the configuration settings for Git, such as user name, email, and other settings.
Q5. Which command would we use to view pending changes?
- git clone
- git status
- git config -l
- git log
Explanation: The git status
command shows the current state of the working directory and staging area, including any pending changes that are yet to be committed.
Module 01 Challenge: Introduction to Git Quiz Answers
Q1. Which of the following best describes Git?
Answer: A version control system
Explanation: Git is a distributed version control system that tracks changes to files and allows multiple users to collaborate on projects.
Q2. What is the first step to create a new repository in Git?
Answer: Initialize a new repository using git init
Explanation: The git init
command is used to initialize a new Git repository in a directory, turning it into a version-controlled project.
Q3. What is the purpose of the git config command?
Answer: To configure global or repository-specific settings
Explanation: The git config
command is used to set configuration options, such as your username, email, and other repository settings.
Q4. What is the best description of a repository from the choices below?
Answer: A repository is a location where all the files of a particular project are stored.
Explanation: A Git repository is a storage space where all the files and the version history of a project are stored.
Q5. Which of the following is a way to verify that Git has been correctly installed on your machine?
- Check that the Git repository exists in your file system
- Open Git in a web browser
- Run git –version in the terminal
- Check that the Git directory exists in your file system
Answer: Run git –version in the terminal
Explanation: Running git --version
in the terminal will show the installed version of Git, confirming that Git is installed correctly.
Q6. When viewing the status of files of the project, where are the files listed that Git is not yet tracking?
Answer: Under “Untracked files”
Explanation: Git lists files that are not yet being tracked under “Untracked files” when you run the git status
command.
Q7. What effect does the git add command have on the repository?
Answer: It changes the status of the repository.
Explanation: The git add
command stages changes, meaning it updates the repository’s index with the modifications made to files.
Q8. What is the command used to capture a snapshot of the project’s currently staged changes with the commit message?
Answer: git commit
Explanation: The git commit
command captures a snapshot of the staged changes and records them in the repository with a commit message.
Q9. What command would you use to add the commit message “Revisions complete” at the same time you enter a git commit command?
Answer: git commit -m “Revisions complete”
Explanation: The git commit -m
command allows you to add a commit message directly, indicating what changes were made in the commit.
Q10. What will the git log command display (if you have not used any options to limit the output of this command)?
Answer: The commit history of the repository
Explanation: The git log
command shows the full history of commits, including commit IDs, dates, authors, and messages for each commit.
Introduction to Git and GitHub Graded Assessment Answers
SRC
Introduction to Git and GitHub Module 02 Quiz Answers
Advanced Git Interaction Practice Quiz Answers
Q1. Which of the following commands is NOT an example of a method for comparing or reviewing the changes made to a file?
- git log -p
- git diff –staged
- git add -p
- git mv
Explanation: git mv
is used to move or rename files within a repository. The other commands (git log -p
, git diff --staged
, git add -p
) are used for comparing or reviewing changes.
Q2. What is the gitignore file?
- A file containing a list of commands that Git will ignore.
- A file the user is intended to ignore.
- A file listing uncommitted changes.
- A file containing a list of files or filename patterns for Git to skip for the current repo.
Explanation: The .gitignore
file lists files or patterns that Git should ignore when tracking changes, preventing unnecessary or sensitive files from being added to the repository.
Q3. What kind of file will the command git commit -a not commit?
- Tracked files
- New files
- Old files
- Staged files
Explanation: The git commit -a
command commits all tracked files that have been modified but does not commit new (untracked) files. New files must first be staged with git add
before they are committed.
Q4. What does HEAD represent in Git?
- The subject line of a commit message
- The top portion of a commit
- The currently checked-out snapshot of your project
- The first commit of your project
Explanation: HEAD
in Git refers to the currently checked-out commit or snapshot in your working directory. It usually points to the latest commit on your current branch.
Q5. If we want to show some stats about the changes in a commit, like which files were changed and how many lines were added or removed, what flag should we add to git log?
- –stat
- –patch
- -2
- –pretty
Explanation: The --stat
flag with git log
displays a summary of changes in a commit, including which files were changed and how many lines were added or removed.
Undoing Things Practice Quiz Answers
Q1. Let’s say we’ve made a mistake in our latest commit to a public branch. Which of the following commands is the best option for fixing our mistake?
- git revert
- git commit –amend
- git reset
- git checkout —
Explanation: git commit --amend
allows you to modify the most recent commit (e.g., to correct a mistake) and create a new commit with the amended changes, without altering the history of public branches.
Q2. If we want to roll back a commit on a public branch that wasn’t the most recent one using the revert command, what must we do?
- Use the git reset HEAD~2 command instead of revert
- Use the revert command repeatedly until we’ve reached the one we want
- Use the commit ID at the end of the git revert command
- Use the git commit –amend command instead
Explanation: To revert a specific commit in Git (that isn’t the most recent), you must use git revert <commit ID>
, where <commit ID>
is the identifier of the commit you want to undo.
Q3. What does Git use cryptographic hash keys for?
- To secure project backups
- To guarantee the consistency of our repository
- To encrypt passwords
- To identify commits
Explanation: Git uses cryptographic hash keys (SHA-1) to uniquely identify commits. Each commit in Git has a hash that serves as a unique identifier.
Q4. What does the command git commit –amend do?
- Start a new branch
- Create a copy of the previous commit
- Delete the previous commit
- Overwrite the previous commit
Explanation: git commit --amend
allows you to modify the most recent commit. It effectively overwrites the previous commit with new changes, including an updated commit message or file content.
Q5. How can we easily view the log message and diff output the last commit if we don’t know the commit ID?
- git show
- git identify
- git log
- git revert
Explanation: The git show
command displays detailed information about the most recent commit, including its log message and the differences (diff) between the committed files and the previous state.
Practice Quiz: Branching & Merging
Q1. When we merge two branches, one of two algorithms is used. If the branches have diverged, which algorithm is used?
- three-way merge
- fast-forward merge
- merge conflict
- orphan-creating merge
Explanation: When two branches have diverged (i.e., they have different changes that are not in common), Git uses a three-way merge. This algorithm compares the changes in the two branches as well as their common ancestor and merges them into a single commit.
Q2. The following code snippet represents the result of a merge conflict. Edit the code to fix the conflict and keep the version represented by the current branch.
print("Keep me!")
Q3. What command would we use to throw away a merge, and start over?
- git checkout -b
- git merge –abort
- git log –graph –oneline
- git branch -D
Explanation: The git merge --abort
command is used to stop and discard the merge process if there are conflicts, allowing you to start the merge process over from the point before the merge was initiated.
Q4. How do we display a summarized view of the commit history for a repo, showing one line per commit?
- git log –format=short
- git branch -D
- git log –graph –oneline
- git checkout -b
Explanation: The git log --graph --oneline
command displays a summarized, linear view of the commit history. It shows a graphical representation of branches and commits, with each commit shown on a single line.
Q5. The following script contains the result of a merge conflict. Edit the code to fix the conflict, so that both versions are included.
def main():
print("Start of program") # From HEAD
print("End of program!") # From improvement-to-the-code
main()
Module 02 Challenge: Merging Branches in Git Quiz Answers
Q1. What is the purpose of the “git commit” command, and how does it contribute to the version control process?
Answer: The “git commit” command is used to save the current state of changes in the local repository, creating a snapshot of the code at that point in time and enabling a detailed history of revisions.
Explanation: The git commit
command is used to capture the current state of the project, making it part of the version history. It helps in tracking changes over time and enables developers to revert or reference specific points in the codebase.
Q2. In the given Git repository named “food-scripts,” what command can be used to view the commit history, including the author’s name, email, date, and commit message?
Answer: git log
Explanation: The git log
command shows the commit history, including details like the author’s name, email, date, and the commit message. It is used to track changes made over time.
Q3. What command would you use to create a patch file that represents the changes between the current working directory and the latest commit?
Answer: git diff > changes.patch
Explanation: The git diff > changes.patch
command generates a patch file containing the changes between the current working directory and the latest commit. This file can be used to share or apply changes to another repository.
Q4. When collaborating with a team on a Git project, what is the main purpose of a remote repository?
Answer: To function as a central repository where all team members can push and pull changes
Explanation: A remote repository acts as a shared central point where developers collaborate by pushing their changes and pulling updates made by others.
Q5. In the lab, after merging the “improve-output” branch into the “master” branch, what type of merge is indicated by the message “Fast-forward”?
Answer: It’s a merge where the master branch moves forward to include the changes from the feature branch.
Explanation: A “fast-forward” merge happens when there is no divergence between the branches, meaning the master branch can be directly moved forward to include the changes from the feature branch without the need for a merge commit.
Q6. Which Git command is used to create a new branch in a Git repository?
Answer: git branch
Explanation: The git branch
command is used to create a new branch in the Git repository. It allows developers to isolate features or bug fixes from the main codebase.
Q7. What command can you use in Git to view the commit history of a repository, including details such as the commit’s SHA-1 checksum, author’s name and email, date, and commit message?
Answer: git log
Explanation: The git log
command displays the commit history, including commit IDs (SHA-1), author details, date, and the commit message. It’s essential for tracking changes and understanding the history of a repository.
Q8. In the lab’s Git operation, what does the “git merge improve-output” command achieve?
Answer: It combines the changes from the improve-output branch into the master branch.
Explanation: The git merge improve-output
command is used to incorporate the changes from the “improve-output” branch into the branch you are currently on (in this case, likely the master branch).
Q9. When would you typically create a new branch in a Git repository?
Answer: To work on a new feature or bug fix without disrupting the main code
Explanation: Creating a new branch in Git allows developers to work on new features or bug fixes in isolation, ensuring the main codebase remains stable until changes are ready to be merged.
Q10. In a Git repository, what is the purpose of the “git pull” command?
Answer: To merge changes from a remote repository into the current branch
Explanation: The git pull
command is used to fetch changes from a remote repository and merge them into the current branch. It combines both fetching and merging in one step.
Introduction to Git and GitHub Graded Assessment Answers
SRC
Introduction to Git and GitHub Module 03 Quiz Answers
Introduction to GitHub Practice Quiz Answers
Q1. When we want to update our local repository to reflect changes made in the remote repository, which command would we use?
- git clone
- git push
- git pull
- git commit -a -m
Explanation: The git pull
command fetches changes from the remote repository and merges them into the current branch of the local repository, keeping it updated with the remote.
Q2. git config –global credential. helper cache allows us to configure the credential helper, which is used for …what?
- Troubleshooting the login process
- Dynamically suggesting commit messages
- Allowing configuration of automatic repository pulling
- Allowing automated login to GitHub
Explanation: The git config --global credential.helper cache
command configures Git to remember credentials (such as your username and password) for a specified time period, preventing the need to re-enter them when pushing or pulling changes.
Q3. Name two ways to avoid having to enter our password when retrieving and when pushing changes to the repo. (Check all that apply)
- Implement a post-receive hook
- Use a credential helper
- Create an SSH key-pair
- Use the git commit -a -m command.
Explanation: Using a credential helper stores and reuses credentials automatically, while setting up an SSH key-pair allows you to authenticate with GitHub (or other Git servers) without needing to enter a password each time.
Q4. Before we have a local copy of a commit, we should download one using which command?
- git commit -a -m
- git push
- git pull
- git clone
Explanation: The git push
command uploads the committed changes from the local repository to the remote repository, ensuring that the remote is updated with the latest snapshots.
Using a Remote Repository Practice Quiz Answers
Q1. In order to get the contents of a remote branch without automatically merging, which of these commands should we use?
- git pull
- git remote update
- git checkout
- git log -p -1
Explanation: The git remote update
command downloads the contents of remote branches to the local repository without merging them into the current working branch. It allows you to review the changes before merging them manually.
Q2. If we need to find more information about a remote branch, which command will help us?
- git fetch
- git checkout
- git remote update
- git remote show origin
Explanation: The git remote show origin
command provides detailed information about the remote repository, including information about the branches and their relationship with local branches.
Q3. What command will download remote branches from remote repositories without merging the content with your current workspace automatically?
- git checkout
- git pull
- git fetch
- git remote update
Explanation: The git remote update
command downloads updates from remote branches, but it does not automatically merge them with your current working branch. This allows you to inspect the changes before incorporating them.
Q4. What type of merge creates a new merge commit?
- Fast-forward merge
- Implicit merge
- Explicit merge
- Squash on merge
Explanation: An explicit merge creates a new merge commit, which represents the merge of two separate branches, even if there are no conflicts. It maintains the history of both branches in the repository.
Q5. What method of getting remote content will automatically merge the remote branch with the current local branch?
- git fetch
- git checkout
- git remote update
- git pull
Explanation: The git pull
command downloads the contents of the remote branch and automatically merges them with the current local branch. This is useful for keeping your branch up to date with the remote repository.
Solving Conflicts Practice Quiz Answers
Q1. If you’re making changes to a local branch while another user has also made changes to the remote branch, which command will trigger a merge?
- git push
- git pull
- git rebase
- git fetch
Explanation: The git pull
command retrieves changes from the remote branch and automatically merges them with your local branch. This is necessary when both local and remote branches have diverged and you want to integrate the changes.
Q2. Which of the following is a reason to use rebase instead of merging?
- When you want to keep a linear commit history
- When you want a set of commits to be clearly grouped together in history
- When you are on a public branch
- When pushing commits to a remote branch
Explanation: Rebasing helps maintain a clean and linear commit history by applying your changes on top of the latest commit in the target branch, as opposed to merging which can create a more complex history with merge commits.
Q3. Where should we keep the latest stable version of the project?
- The master branch
- A separate branch from the master branch
- The debug branch
- A remote branch
Explanation: The master
(or main
) branch is typically where the stable, production-ready version of a project is kept. It reflects the most up-to-date and tested code that can be deployed.
Q4. Which of the following statements represent best practices for collaboration? (check all that apply)
- When working on a big change, it makes sense to have a separate feature branch.
- You should always rebase changes that have been pushed to remote repos.
- Always synchronize your branches before starting any work on your own.
- Avoid having very large changes that modify a lot of different things.
Explanation:
- Using separate feature branches helps isolate work and prevents issues in the main branch.
- Synchronizing branches ensures you’re working with the latest updates and reduces conflicts.
- Making smaller, focused changes makes reviewing and integrating them easier.
Q5. What command would we use to change the base of the current branch?
- git checkout
- git pull
- git rebase
- git fetch
Explanation: The git rebase <branchname>
command is used to change the base of the current branch to another branch, applying the changes from the current branch on top of the specified branch. This is useful for maintaining a linear commit history.
Module 03 challenge: Introduction to GitHub Quiz Answers
Q1. Which of the following steps are involved in creating a Github account? Select all that apply.
Answer:
Choosing a username
Choosing a password
Providing a valid email address
- Explanation:
When creating a GitHub account, you need to select a username, set a password, and provide a valid email address. Downloading the GitHub desktop application is optional, not a required step to create an account.
Q2. If you create a private repository on Github, what will you need to clone the repo via HTTPS?
Answer: Your Github username and your personal access token
Explanation: When cloning a private repository via HTTPS, GitHub requires you to authenticate using your GitHub username and a personal access token instead of a password, as passwords are no longer supported for Git operations.
Q3. After you create a remote repository, you need to create a local copy of this remote repository on your machine. What is the syntax for this process?
Answer: git clone [URL]
Explanation: To create a local copy of a remote repository, use the git clone [URL]
command. You do not need to specify a directory name as it will automatically create a folder for the repository.
Q4. After you set a Github username, any future commits you push to GitHub from the command line will be represented by this name. What happens if you change the name associated with your Git commits?
Answer: This will only affect future commits and won't change the name used for past commits.
Explanation: Changing your Git username will only affect future commits. It does not alter the name used for past commits, as those are already recorded in the commit history.
Q5. What is the command to add content from the working directory into the staging area for the next commit?
Answer: git add
Explanation: The git add
command is used to move changes from the working directory to the staging area, making them ready to be committed.
Q6. Git uses the term “commit”. In more common terms, how would you describe a commit?
Answer: Git commit is like saving your work.
Explanation: A commit in Git is similar to saving your work; it records the current state of the files in the repository, making a snapshot of the changes.
Q7. Which of the following commands will create a snapshot of the current state of the repository in Git?
Answer: git commit
Explanation: The git commit
command creates a snapshot of the current state of the repository, recording the changes made to the tracked files.
Q8. When you use the git commit command, it takes a snapshot of your current work. Where is the work the commit takes a snapshot of?
Answer: The staging area
Explanation: The git commit
command takes a snapshot of the staged changes (i.e., the staging area) rather than the working directory.
Q9. Recently, you added files on a remote repository, but those files aren’t yet present on your local repository. What will happen if you try to push something from the local repository to the remote repository?
Answer: Your attempt will return an error.
Explanation: If the local repository is behind the remote repository (i.e., it lacks changes made remotely), attempting to push will return an error. You need to pull first to synchronize with the remote repository.
Q10. What command is used to push changes from the local repository to the remote repository?
Answer: git push origin main
Explanation: The git push origin main
command is used to push the local commits to the remote repository, specifically to the main
branch.
Introduction to Git and GitHub Peer Graded Assessment Answers
Resources
Introduction to Git and GitHub Module 04 Quiz Answers
Pull Requests Practice Quiz Answers
Q1. What is the difference between using squash and fixup when rebasing?
- Squash deletes previous commits.
- Squash combines the commit messages into one. Fixup discards the new commit message.
- Squash only works on Apple operating systems.
- Fixup combines the commit messages into one. Squash discards the commit message.
Correct
Explanation: Both squash
and fixup
combine commits during a rebase, but squash
keeps the commit message of the combined commits, while fixup
discards the commit message of the commit being fixed up, only keeping the message of the earlier commit.
Q2. What is a pull request?
- The owner of the target repository requesting you to add your changes.
- A request sent to the owner and collaborators of the target repository to pull your recent changes.
- A request to delete previous changes.
- A request for a specific feature in the next version.
Explanation: A pull request is a way to propose changes to a repository, allowing the maintainers to review and decide whether to merge your changes into the main branch.
Q3. Under what circumstances is a new fork created?
- When you want to experiment with changes without affecting the main repository.
- When you clone a remote repository to your local machine.
- During a merge conflict.
- When there are too many branches.
Explanation: A fork is typically created when you want to make changes to a project independently without affecting the original repository. This is common for contributing to open source projects.
Q4. What combination of command and flags will force Git to push the current snapshot to the repo as it is, possibly resulting in permanent data loss?
- git push -f
- git log –graph –oneline –all
- git status
- git rebase -i
Explanation: The git push -f
(force push) command forces Git to push the current snapshot to the repository, potentially overwriting changes and causing data loss if not used carefully.
Q5. When using interactive rebase, which option is the default, and takes the commits and rebases them against the branch we selected?
- squash
- edit
- reword
- pick
Explanation: The pick
option is the default in interactive rebase. It means that Git will keep the commit as is and apply it to the new base (branch). Other options like edit
, reword
, and squash
modify the commits in some way.
Code Reviews Practice Quiz Answers
Q1. When should we respond to comments from collaborators and reviewers?
- When their comments address software-breaking bugs
- No need, just resolve the concerns and be done with it
- Always
- Only when a code correction is necessary
Explanation: Responding to comments from collaborators and reviewers is important for collaboration and ensuring that all concerns are addressed. Ignoring comments could lead to misunderstandings or unresolved issues.
Q2. What is a nit?
- A trivial comment or suggestion
- A couple lines of code
- A repository that is no longer maintained
- An orphaned branch
Explanation: A “nit” is a minor or trivial comment, often related to style or readability, that doesn’t affect the functionality of the code but can improve clarity or consistency.
Q3. Select common code issues that might be addressed in a code review. (Check all that apply)
- Using unclear names
- Following PEP8 guidelines
- Forgetting to handle a specific condition
- Forgetting to add tests
Explanation: Code reviews often address issues such as unclear variable names, adherence to style guides (like PEP8), missing edge case handling, and the absence of tests.
Q4. If we’ve pushed a new version since we’ve made a recent change, what might our comment be flagged as?
- Accepted
- Resolved
- Outdated
- Merged
Explanation: If a new version has been pushed after your change, your comment may be flagged as outdated because it no longer aligns with the current state of the code.
Q5. What are the goals of code review? (Check all that apply)
- Make sure that the contents are easy to understand
- Ensure consistent style
- Build perfect code
- Ensure we don’t forget any important cases
Explanation: The primary goals of code review are to ensure the code is understandable, maintainable, and consistent in style, and to catch any missed edge cases or bugs. Building “perfect” code isn’t always a goal, but improving code quality is.
Managing Collaboration Practice Quiz Answers
Q1. How do we reference issues in our commits with automatic links?
- By using one of the keywords followed by a hashtag and the issue number.
- By using an asterisk (*) after the issue number.
- By typing the issue number inside braces ({}).
- By using a special keyword.
Explanation: To reference issues in commits and create automatic links, you use keywords like “fixes,” “closes,” or “resolves” followed by the issue number preceded by a hashtag (e.g., fixes #123
).
Q2. What is an artifact in terms of continuous integration/continuous delivery (CI/CD) pipelines?
- An old and obsolete piece of code or library.
- Any file generated as part of the CI/CD pipeline.
- An unintended minor glitch in a computer program
- An automated series of tests that run each time there is a new commit or pull request.
Explanation: Artifacts in CI/CD refer to files generated during the build or deployment process, such as compiled code, test reports, or logs, that are stored for later use or delivery.
Q3. Which of the following statements are good advice for project maintainers? (Check all that apply)
- Coordinate solely via email
- Reply promptly to pull-requests
- Understand any changes you accept
- Use an issue tracker
Explanation: Good project maintainers should be responsive to pull requests, review changes thoroughly, and manage tasks and bugs with an issue tracker for better organization.
Q4. Which statement best represents what a Continuous Integration system will do?
- Run tests automatically
- Update with incremental rollouts
- Assign issues and track who’s doing what
- Specify the steps that need to run to get the result you want
Explanation: Continuous Integration (CI) involves automating the process of testing and integrating changes into the codebase, usually by running tests each time new code is committed.
Q5. Which statement best represents what a Continuous Delivery (CD) system will do?
- Run tests automatically
- Update with incremental rollouts
- Assign issues and track who’s doing what
- Specify the steps that need to run to get the result you want
Explanation: Continuous Delivery (CD) automates the process of deploying code to production, typically with incremental rollouts, ensuring changes are delivered continuously and reliably.
Module 04 challenge: Push local commits to Github Quiz Answers
Q1. Why is it important to communicate with your team before pushing changes to the remote repository after resolving a merge conflict?
Answer: All of these reasons
Explanation: Communicating with the team ensures no one is working on the same files, that any further changes are pulled, and that others are informed of your changes before they are merged into the remote repository.
Q2. Which command will you use to check the states of your Git repository?
Answer: git status
Explanation: The git status
command shows the current state of the repository, including any changes that have been staged, changes that are not yet staged, and untracked files.
Q3. Why is it important to include a descriptive message with each commit to a Version Control System?
Answer: To help other developers understand the changes
Explanation: Descriptive commit messages provide context to other developers about the purpose of changes, making it easier to understand the project’s history and why changes were made.
Q4. When reviewing a pull request, what is important to look for?
Answer: The readability of the code.
Explanation: The readability of the code is crucial as it ensures other developers can understand and maintain the code. The code should also be functional, efficient, and follow best practices.
Q5. What is the purpose of the “Merge” button in a Git pull request on platforms like GitHub or GitLab?
Answer: To finalize the pull request, merge the changes into the target branch, and close the pull request.
Explanation: The “Merge” button completes the pull request process by integrating the changes into the target branch and closing the request.
Q6. Which of the following is NOT a benefit of using pull requests in GitHub?
Answer: They automatically resolve merge conflicts
Explanation: Pull requests do not automatically resolve merge conflicts. They are a means for proposing changes, discussing them, and reviewing them before merging, but conflicts need to be manually resolved.
Q7. What does a code review in GitHub involve?
Answer: Evaluating the quality of the code and suggesting improvements
Explanation: A code review involves evaluating the quality of the code, suggesting improvements, and ensuring that the code follows best practices and is free from bugs.
Q8. What should you look for in a code review on GitHub?
Answer: All of the above
Explanation: In a code review, you should look for bugs, clarity and readability, and adherence to coding standards and best practices.
Q9. What does it mean when a GitHub pull request has a green ‘Merged’ badge?
Answer: The pull request has been merged into the base branch
Explanation: The green ‘Merged’ badge indicates that the changes in the pull request have been successfully merged into the base branch.
Q10. What is the primary purpose of creating a fork of a repository?
Answer: To contribute changes to the original repository through pull requests
Explanation: A fork allows you to create your own copy of a repository where you can make changes, which can later be submitted to the original repository via a pull request.
Next Quiz Answers >>
Troubleshooting and Debugging Techniques
<< Previous Quiz Answers
Using Python to interact with the Operating System
All Quiz Answers of Google IT Automation with Python Professional Certificate
Course 1: Crash Course on Python
Course 2: Using Python to interact with the Operating System
Course 3: Introduction to Git and GitHub
Course 4: Troubleshooting and Debugging Techniques
Course 5: Configuration Management and the Cloud
Course 6: Automating Real-World Tasks with Python