Introduction to Git and GitHub Coursera Quiz Answers | 100% Correct Answers

About Introduction to Git and GitHub Course

In this course, you’ll learn how to keep track of the different versions of your code and configuration files using a popular version control system (VCS) called Git. We’ll also go through how to set up an account with a service called GitHub so that you can create your very own remote repositories to store your code and configuration.

Throughout this course, you’ll learn about Git’s core functionality so you can understand how and why it’s used in organizations. We’ll look into both basic and more advanced features, like branches and merging.

We’ll demonstrate how having a working knowledge of a VCS like Git can be a lifesaver in emergency situations or when debugging. And then we’ll explore how to use a VCS to work with others through remote repositories, like the ones provided by GitHub.

By the end of this course, you’ll be able to store your code’s history in Git and collaborate with others in GitHub, where you’ll also start creating your own portfolio!

In order to follow along and complete the assessments, you’ll need a computer where you can install Git or ask your administrator to install it for you.

Enroll in this Course

Introduction to Git and GitHub Coursera Quiz Answers

Week 1: Introduction to Version Control

Practice Quiz: Before Version Control

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

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

Q3. The _ command highlights the words that changed in a file instead of working line by line.

  • diff
  • diff -u
  • vimdiff
  • patch

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

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

Practice Quiz: Version Control Systems

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.

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

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

Q4. A _ is a collection of edits that have been submitted to the version control system for safekeeping.

  • IDE
  • version control system
  • commit
  • repository

Q5. Within a VCS, project files are organized in centralized locations called _ where they can be called upon later.

  • commits
  • repositories
  • IDE
  • yum

Practice Quiz: Using Git

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

Q2. Which command would we use to review the commit history for our project?

  • git clone
  • git status
  • git config -l
  • git log

Q3. What command would we use to make Git track our file?

  • git clone
  • git status
  • git add
  • git log

Q4. Which command would we use to look at our config?

  • git clone
  • git status
  • git config -l
  • git log

Q5. Which command would we use to view pending changes?

  • git clone
  • git status
  • git config -l
  • git log

Graded Assessment

Click here to Download

SRC

Click here to Download

Week 2: Using Git Locally

Practice Quiz: Advanced Git Interaction

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

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.

Q3. What kind of file will the command git commit -a not commit?

  • Tracked files
  • New files
  • Old files
  • Staged files

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

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

Practice Quiz: Undoing Things

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 —

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

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

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

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

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

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

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

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>>>>>>>")
    print("End of program!")

main()

Graded Assessment

Click here to Download

SRC

Click here to Download

Week 3: Working With Remotes

Practice Quiz: Introduction to GitHub

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

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

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.

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

Practice Quiz: Using a Remote Repository

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

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

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

Q4. What type of merge creates a new merge commit?

  • Fast-forward merge
  • Implicit merge
  • Explicit merge
  • Squash on merge

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

Practice Quiz: Solving Conflicts

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

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

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

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.

Q5. What command would we use to change the base of the current branch?

  • git checkout
  • git pull
  • git rebase
  • git fetch

Peer Graded Assessment

Click here to Download

Resources

Click here to Download

Week 4: Collaboration

Practice Quiz: Pull Requests

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

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.

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.

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

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

Practice Quiz: Code Reviews

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

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

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

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

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

Practice Quiz: Managing Collaboration

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.

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.

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

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

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

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

2 Comments

Leave a Reply

error: Content is protected !!