linkedin-skill-assessments

Git

Q1. How can you check your current git version?

Q2. What command lets you create a connection between a local and remote repository?

Reference

Q3. Describe what these Git commands do to the commit history:

git reset --hard HEAD~5
git merge --squash HEAD@{1}

Explanation:

Q4. Your current project has several branches; master, beta, and push-notifications. You’ve just finished the notification feature in the push-notification branch, and you want to commit it to beta branch. How can you accomplish this?

Q5. Which of the following is true you when you use the following command?

git add -A

Q6. What will the following command print to the Terminal?

git remote -v

Q7. Looking at the following commands, describe what is happening.

git checkout feature-user-location
git cherry-pick kj2342134sdf090093f0sdgasdf99sdfo992mmmf9921231

Explanation: Commits aren’t copied when cherry picking, they are cherry picked. The changes introduced by the commit are applied and a new commit is then created. This allow us to get specific changes as if they were patches (in the GIT’s book, this is actually called Patching). As a new commit is created upon feature-user-location, HEAD also changes to match it. You can see this in cat .git/HEAD and cat .git/refs/heads/feature-user-location for this case. See man git-cherry-pick for details.

NOTE: There are two versions of this question so far. The task is always “describe what is happening”, the commands are always a checkout and a cherry-pick, and the correct answer is always the same.

Q8. What does the following command do to the git repository?

git reset --soft HEAD^

Q9. You find a bug in your project, but can’t locate where it was introduced in the commit history. How would you diagnose this problem?

Q10. Why would the following command be used?

git rebase -i HEAD~10

Q11. Why would you use a pre-receive hook in your remote repository?

Q12. What option can you use to apply git configurations across your entire git environment?

Q13. How could you squash multiple commits together without using git merge --squash?

Q14. If you cloned an existing git repository, what would happen?

Q15. How can you display a list of files added or modified in a specific commit?

Q16. What files is this .gitignore programmed to leave out?

#.swift
build/

*.txt
*.metadata

A line starting with # serves as a comment. Hence # .swift does not do anything. See man gitignore.

Q17. After you make changes to a local repository, you run the following command. What will this do?

git commit -a -m "Refactor code base"

Q18. After checking your git status you get the following output, which shows the file beta-notes.js in the commit but also unstaged. How can this situation occur?

Change to be committed:

(use "git reset HEAD <file>..." to unstage)
modified: beta-notes.js
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout --<file>..." to discard changes in working directory)

modified: beta-notes.js

Q19. Where are files stored before they are committed to the local repository?

Q20. What commands would you use to force an overwrite of your local files with the master branch?

Q21. Which statement is true when you use the git add -A command?

Q22. You find that your project has a tag and branch both named push-notifications, which causes confusion when trying to print out given reference. How can you specify which branch you want to look at?

Reference

Q23. Your team lead needs a list of all commits that will be moved before you perform a rebase. Which command can you use to access that information?

Q24. What is the operation doing given the Git commands below?

git bisect start
git bisect bad 5d41402abc4b2a76b9719d911017c592
git bisect good 69faab6268350295550de7d587bc323d

Q25. In a situation where you have several commits for a single task, what is the most efficient way to restructure your commit history?

Q26. Which of the following is true of the git push command?

Reference

Q27. After pushing commits to the remote repository for the first time using the command below, what shorthand command can you use in future?

git push -u origin master

Q28. How would you create a custom shortcut or command across your git environment?

Q29. What is the status of the beta-notes.js file in the following output?

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: beta-notes.js

Q30. What command would let you modify your previous commit?

Q31. What is the best way to characterize the git commit structure?

Q32. What change will the following command make to the staging area files?

git rm --cached testfile.js

Q33. After you’ve successfully merged two branches and committed the changes, what is the next step in keeping your git structure organized?

Q34. While modifying a file, you’re unexpectedly assigned an urgent bug fix on another branch. How can you temporarily save your local work without committing?

Q35. What command would you use to create a new git repository?

Q36. While working on a feature branch you try to use “git rerere” to solve a recurring merge conflict but nothing is happening. What could be causing this issue?

Q37. Which setting determines what pager is used when Git pages output?

Q38. What does commit object contain?

Q39. Which option enables inclusion of committer name in custom log format?

Q40. How many ways are present in Git to integrate changes from one branch into another?

Reference link In Git, there are two main ways to integrate changes from one branch into another: the merge and the rebase.

Q41. Which user should be created first during setting up of SSH?

Q42. Which command will list tags with the 1.4.2 series?

Q43. Which of the following is an integration manager?

Q44. Which Git command begins tracking of a new file?

Q45. Which of the following is called dumb protocol?

Q46. Which key press returns a set of suggestions to pick from, when writing a Git command?

Q47. Which of these terms best describes Git?

Q48. Which command gets a copy of an existing Git repository?

Q49. How does Git think of its data?

Q50. Which option enables inclusion of author name in custom log format?

Q51. Which version onwards did Git offer reversing a file back to what it looked like when last committed?

Q52. Which strategy is used by Git for merging two branches?

Q53. What does refs store?

Q54. What Language is used in GIT?

Q55. What is usually the extension of file which has the public key?

Q56. What is the difference between initializing a normal repo and a bare repo?

Q57. How many individual commits can a single repository have?

Q58. What types of tags does Git support?

Q59. After staging a series of changes to the index, which command could you use to review them prior to a commit?

Q60. What does the git stash drop command do?

Q61. What command creates a new branch from the currently checked-out branch?

Q62. After mistakenly staging a file named myFile to the index, how would you remove it from the index to exclude it from your next commit?

Q63. What happens if you run this command from your master branch?

git checkout -b beta-test

Q64. How does Git internally manage branches?

Q65. You want to perform a git reset but cannot recall all of the available options. What command would you use to see a description of them?

Q66. What is a remote repository?

Q67. After modifying some existing files in a repository, you decide to discard the changes. What command can you use?

Q68. After starting to merge a feature branch into your master branch, you encounter a merge conflict and decide you do not want to perform the merge. How can you stop the merge and restore to the pre-merge state?

Q69. If you have several commits for a single feature, what is the most efficient way to restructure your commit history?

Q70. Which command correctly creates a lightweight tag?

Q71. What is the main issue with using git rebase when working with multiple developers?

Q72. What Git workflow is used by teams that collaborate on a single branch and avoid creating long-lived development branches?

Q73. Which option on the git log command allows you to limit output to commits made after certain date?

Q74. How would you delete unreachable objects older than a specified time from your project database?

Q75. What conflicts can occur when forcing a push after rebasing?

Q76. How does this command alter the currently checked-out branch?

git reset --soft HEAD^

Q77. What is the difference between Git and SVN?

Q78. This command is an example of what kind of tag?

git tag -a v1.4 -m "ABCD v1.5"

Q79. What is the difference between a soft reset (git reset --soft) and a hard reset (git reset –hard) ?

Q80. Consider the following Git workflow:

image Which of the following options is correct ?

Q81. What information does the git config file store?

Reference

Q82. What is version control?

Q83. What is the difference between using the git stash and git stash pop commands?

Q84. Which command can be used to list the branches that have been merged into the currently checked-out branch?

Q85. How would you configure Git to abort a commit if a smoke test script fails?

Q86. Which use case is NOT a good candidate for a Git hook?

Q88. What information do Git reflogs (reference logs) store?

Q89. You have just completed rebasing your master branch and need to manually update the remote master, even though there is a merge conflict. How can you accomplish this?

Q90. What is the difference between git fetch and git pull

Q91. What command displays the difference between the working tree and the stage/index area, as well as files not tracked by Git?

Q92. You would like to restore some previously stashed work to a new branch. How can you do that?

reference here

Q93. What is the difference between git branch -d and git branch -D?

Q94. You stashed three sets of changes but cannot remember the contents of the first stash entry. What command would you use to see the details of the changes in the first of the three stash entries?

reference here

Q95. How would you delete a remote branch in your repository?

reference here

Q96. What is the default setting of git reflog when no subcommands are specified?

reference here

Q97. How does the -p option change the behavior of the git add command

reference here

Q98. After checking out a specific commit, you receive a warning message indicating You are in ‘detached HEAD’ state. What is Git warning you of?

reference here

Q99. After accidentally deleting a branch in your local repository, how can you recover it?

Reference

Q100. How would you display a histogram showing inserts, deletion, and modifications per file for a specific commit along with its general commit information?

Reference

Q101. What features do repository managers such as GitHub provide beyond Git?

reference

Q102. What command finds the HEAD of the current branch?

reference

Q103. When Git Workflows contain a long-running branch, what purpose does the long-running branch serve?

Q104. What command takes changes from the master branch on the remote repository origin and merges then to the local checked-out branch?

Q105. While pushing changes to a remote repository, you receive the following message. How do you resolve this issue?

error: failed to push some refs to 'https://github.com/myrepo/simple.git'
hint: Updates were rejected because the remote contains work that you do not hint: not have locally.

Q106. What does the -p option add to the output of the git log command?

Q107. What is the staging area or index?

Q108. What command would you use to stage changes to the index strictly for properties files in the current directory?

Q109. What are untracked files?

Q110. What type of Git hook could be used to validate that a commit message contains a ticket number?

Q111. What is the difference between git stash pop and git stash apply?

Q112. After making some major changes to your code, you are a little nervous about committing. What command would you use to review the commit prior to making it?

Q113. What statement best describes Git’s concept of HEAD?

Q114. After staging changes to several files, you realize the changes to the config.properties file are incorrect, and need to be removed from the stage and working directory. What command can you use to remove the staged changes to the file?

Q115. After a recent release with a stack trace, an issue is create that indicates the problem is with a newly added configuration property named MaxConnections. What command can find all commits that add or remove the string MaxConnections?

Q116. Your company has moved its remote repository to GitHub at this location: https://github.com/yourcompany/core-api.git. What command updates the remote repository, named origin, to point to the new remote repository at this location?

Q117. When is the cherry-pick command used?

Q118. How would you describe a forked repository?

reference

Q119. How can you exclude untracked files within the working directory from a Git repository?

reference

Q120. What command creates a near-exact copy of the entire repository from a server?

Q121. What would happen if you ran the git reset testfile.js command?

Q122. What situation can occur when attempting to combine branches containing changes to the same piece of code?

Q123. When Git workflows contain a topic branch, what purpose does the topic branch serve?

Q124. What practice can help reduce the chances of encountering a merge conflict?

Q125. You have changed your mind about adding broccoli to your project. How should you remove it?

Untracked files:
  (use "git add <file>..." to include in what will be committed)
  brccoli

Q126. What command can you use to remove untracked files from the working directory?

Q127. After making a commit, you notice that you forgot to include changes to the doge.txt file. What command or commands would you use to add the changes to the commit ?

Q128. Which command would remove a file named wrongfile from the current branch of a repository, the index, and working files?

git rm wrongfile
git commit -m "Removed file"

Q129. What is the best way to report a bug to a GitHub project?

Explanation: A project’s issues are visible to anyone who has access to the project, so you may find a resolution is already planned or available. Otherwise, you can create and track the issue yourself.

Q130. Suppose you have created a bug fix on a new branch and want it to become part of the next production build generated from the main branch. What should you do next?

Explanation: Pull requests are the correct way to communicate that commits are ready for review and ultimate inclusion on the main branch.

Q131. Which command would remove a file named wrongfile from the current branch of a repository, the index, and working files?

Explanation: GitHub provides forking functionality designed to allow you to work with projects where you aren’t an owner or don’t have write access. Forking makes a remote copy of the project in your repository that you can then clone locally. To submit updates to the target repository (upstream repository) you can submit a pull request.

Q132. What is GitHub?

Explanation: GitHub is a popular hosting platform for developers to store their Git repositories and collaborate with other developers all around the world.

Q133. Which statement is true of the git push command?

Q134. Git Pull is a combination of?

Q135. What is the command to set the user email for the current repository?