1. 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
2. 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.
3. What kind of file will the command git commit -a not commit?
- Tracked files
- New files
- Old files
- Staged files
4. 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
5. 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
6. 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 — <file>
7. If we want to rollback 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
8. 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
9. 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
10. What is the gitignore file?
- git show
- git identify
- git log
- git revert
11. 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
12. 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.
<<<<<<< HEAD
print(“Keep me!”)
=======
print(“No, keep me instead!”)
>>>>>>> brancho-cucamonga
- print(“Keep me!”)
13. What command would we use to throw away a merge, and start over?
- git checkout -b <branch>
- git merge –abort
- git log –graph –oneline
- git branch -D <name>
14. 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 <name>
- git log –graph –oneline
- git checkout -b <branch>
15. 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():
<<<<<<< HEAD
print(“Start of program>>>>>>>”)
=======
print(“End of program!”)
>>>>>>> improvement-to-the-code
main()
Answers
def main():
print(“Start of program>>>>>>>”)
print(“End of program!”)
main()