They reset the HEAD to the fifth commit in the repo, then merge to the master branch.
The current branch's HEAD is reset back five commits, then prior commits are squashed into a single commit.
They delete the last five commits.
They merge the last five commits into a new branch.
Explanation:
git reset --hard HEAD~5 resets the current branch to the commit just before the last 5 (see man gitrevisions for details about this notation and other cool alternatives like HEAD@{2 days ago}). As it is a hard reset, it will also overwrite every change in the working tree as well. See man git-reset.
git merge --squash HEAD@{1} HEAD@{1} is where the branch was just before the previous command (again, see man gitrevisions). This command sets the state of the index to be as it would just after a merge from that commit. This whole operation could be a way to take 5 commits from a branch in which you started a new feature and squash them to a single commit, a meaningful one.
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?
Checkout the push-notifications branch and run git merge beta
Checkout the master branch and run git merge beta -> push-notifications
Delete the push-notifications branch and it will be committed to the master branch automatically
Checkout the beta branch and run git merge push-notifications
The commit is being tagged for release on the feature-user-location branch
A commit is being copied from its original branch over to the feature-user-location branch
The commit is being cherry picked as the new HEAD of the commit history
A commit is being copied from the feature-user-location branch to the master branch
The branch is switched to the feature-user-location branch, and the specified commit is applied to the branch.
Explanation:
'git checkout feature-user-location' switches to the 'feature-user-location' branch.
'git cherry-pick kj2342134sdf090093f0sdgasdf99sdfo992mmmf9921231' applies the changes from the specified commit ('kj2342134sdf090093f0sdgasdf99sdfo992mmmf9921231') to the current branch (feature-user-location). This effectively copies the commit from its original branch to the feature-user-location branch.
So, this sequence of commands is cherry-picking a specific commit onto the feature-user-location branch.
Q8. What does the following command do to the git repository?
git reset --soft HEAD^
It deletes all previous commits and resets the repository history back to its initial state.
It resets the working branch to the first commit.
It keeps the HEAD at the current commit but clears all previous commits.
It sets HEAD to the previous commit and leaves changes from the undone commit in the stage/index.
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"
Nothing, you can't use multiple options in the same command
Adds all new files to the staging area
Commits all new files with a message
Adds all modified files to the staging area, then commits them with a message
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
There were two copies of beta-notes.js but one was deleted
beta-notes.js was staged, then modified afterwards, creating two different versions of the file
Two copies of beta-notes.js were created, but only one is being tracked
There are two tracked copies of beta-notes.js, but one was removed from the commit
Note: - The command pull is fetch followed by either merge or rebase (in this case, merge). We don't want to merge. Merge would be an action to our repository. We just want to overwrite our local files.
Q21. 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?
Q28. 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
beta-notes.js is untracked and has been modified.
beta-notes.js is a tracked file and has been modified, but has not been added to the current commit.
beta-notes.js is untracked but has been added to the current commit.
beta-notes.js is tracked, and the modified file has been added to the current commit.
Q33. 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?
This is not possible, as you cannot save locally without committing.
Run git hold to save a local copy of what you're doing to return to later.
Save your work with git local-cache.
Use git stash to save your work and come back later and reapply the stashed commit.
Q35. 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?
Q36. Which setting determines what pager is used when Git pages output?
core.page
page
pager
core.pager
Q37. What does commit object contain?
A set of files, representing the state of a project at a given point of time.
Reference to parent commit objects.
An SHA1 name, a 40-character string that uniquely identifies the commit object.
Reference to parent commit objects and a set of files, representing the state of a project at a given point of time, and an SHA1 name, a 40-character string that uniquely identifies the commit object.
Q38. Which option enables inclusion of committer name in custom log format?
Q59. What command creates a new branch from the currently checked-out branch?
git -b checkout <nameOfBranch>
git branch
git checkout <nameOfBranch>
git checkout -b <nameOfBranch>
Q60. 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?
Use git reset HEAD^.
Use git reset myFile.txt.
Use git -rm myFile.txt.
Use git reset.
Q61. What happens if you run this command from your master branch?
git checkout -b beta-test
The beta-test branch will be checked out of the current commit.
The beta-test branch will be checked out and deleted.
A new branch called beta-test will be created and switched to.
The beta-test branch will be merged with the master branch.
Q62. How does Git internally manage branches?
by creating a pointer to the most recent snapshot/commit for the branch.
by creating a data array of branches in the same repository.
by creating a data dictionary of code changes.
be creating a debug log that stores repository changes.
Q63. 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?
git help reset
git -h reset
git options reset
git reset help
Q64. What is a remote repository?
a version of the repository that mirrors changes made in the local repository's master branch for open-source collaboration efforts
the lead repository elected by the Git arbitrator found within local repositories of collaborating team members
a read-only version of the repository stored on a backup server in case local repositories become lost or corrupted
a version of the repository hosted on the internet or network that is pushed to or pulled from by collaborators
Q65. After modifying some existing files in a repository, you decide to discard the changes. What command can you use?
git restore
git undo
git clean
git checkout .
Q66. 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?
Use git restore -p.
Use git merge -u.
Use git merge --abort.
Use git merge --undo.
Q67. Which command correctly creates a lightweight tag?
git tag v3.8.1
git tag --light "v3.8.1"
git tag v3.8.1 —-annotate -m "<tagMessage>"
git tag -l v3.8.1
Q68. What is the main issue with using git rebase when working with multiple developers?
Rebase affects only your repository and creates a diff in the master branch.
Rebase creates a temporary copy of the master branch in the remote repo.
Rebase moves the HEAD of the remote master branch one commit forward.
Rebase deletes all commit history for the new feature branch.
Q69. What Git workflow is used by teams that collaborate on a single branch and avoid creating long-lived development branches?
Git flow
Mainline flow
Trunk-Based Development
GitHub flow
Q70. Which option on the git log command allows you to limit output to commits made after certain date?
--since
--sinceWhen
-<n>
--afterDate
Q71. How would you delete unreachable objects older than a specified time from your project database?
git cache --obsolete <time>
git branch --rebase <time>
git delete --inert <time>
git prune --expire <time>
Q72. What conflicts can occur when forcing a push after rebasing?
The remote master branch could have existing changes overwritten.
The origin URL will be reset to its default value.
The current HEAD will be deleted and can't be reinstated.
Nothing, it's common practice to force a push after rebasing.
Q73. What is the difference between Git and SVN?
Git works only on Linux, while SVN works on all operating systems.
SVN works only on Linux, while Git works on all operating systems.
SVN is a centralized system, while Git is a distributed system.
Git a centralized system, while SVN is a distributed system.
Q74. This command is an example of what kind of tag?
git tag -a v1.4 -m "ABCD v1.5"
verbose
annotated
lightweight
deferred
Q75. What is the difference between a soft reset (git reset --soft) and a hard reset (git reset –hard) ?
A soft reset only changes the commit that HEAD points to, while a hard reset resets the index and working tree to match the specified commit, discarding any changes.
A soft reset caches the old HEAD pointer, while a hard reset deletes it entirely.
A hard reset changes only where the HEAD is pointing, while a soft reset changes the HEAD and index.
A hard reset caches the old HEAD pointer, while a soft reset deletes it entirely.
a type of architecture used to manage large databases
a system that shows, tracks, and controls changes to a set of files over time
a programmatic design pattern used to manage code between multiple engineering teams
a type of software that links a project with a GitHub repository
Q79. What is the difference between using the git stash and git stash pop commands?
git stash removes a commit from the repo history, while git stash pop saves changes to multiple branches.
git stash saves changes to multiple branches, while git stash pop removes a commit from the repo history.
git stash removes the most recent commit, while git stash pop saves current changes.
git stash creates a stash entry, while git stash pop places a saved state from the stash list onto the working directory.
Q80. Which command can be used to list the branches that have been merged into the currently checked-out branch?
git master --status
git branch --status
git branch --merged
git status --merged
Q81. How would you configure Git to abort a commit if a smoke test script fails?
Create a post-commit shell script that triggers the action.
Create a post-commit hook to trigger the script.
Create a pre-commit hook to trigger the script.
Create a pre-commit shell script that triggers the action.
Q82. Which use case is NOT a good candidate for a Git hook?
state dependent environment changes
continuous integration
increasing code coverage
enforcing commit rules
Q83. What information do Git reflogs (reference logs) store?
shell script pointers and keychain credentials
updates to branch tips and other references in the local repository
release notes and hook script values
tag and versioning information
Q84. 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?
git push --overwrite
git push --update
git push --assert
git push --force-with-lease
Q85. What is the difference between git fetch and git pull
git fetch creates a new branch off the master branch, while git pull creates a new branch off the local repository's master branch.
git pull downloads new data from a remote repository without integrating it into local files, while git fetch updates the current HEAD branch with the latest changes from the remote server.
git fetch updates remote tracking branches with changes from a remote repository, while git pull updates remote tracking branches with changes from a remote repository and merges them into their corresponding local branches.
git fetch downloads and merges data from the local repository, while git pull informs your colleagues you are about to make changes to the master branch.
Q86. What command displays the difference between the working tree and the stage/index area, as well as files not tracked by Git?
git current
git status
git local
git context
Q87. You would like to restore some previously stashed work to a new branch. How can you do that?
Use git branch <stash hash>.
Add the stashed commits to the current commit, then create a new branch.
Q88. What is the difference between git branch -d and git branch -D?
-D deletes the local branch, while -d deletes the branch regardless of push and merge status.
-d deletes the current commit head, while -D deletes the entire branch.
-d deletes the local branch, while -D deletes the local branch regardless of push and merge status.
-D deletes the current commit head, while -d deletes the entire branch.
Q89. 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?
Q95. How would you display a histogram showing inserts, deletion, and modifications per file for a specific commit along with its general commit information?
Q96. What features do repository managers such as GitHub provide beyond Git?
Repository managers are proprietary versions of Git that do not include enhanced features.
Repository managers provide an enhanced command-line tool that is used to manage multiple local repositories.
Repository managers provide an online service for hosting Git repositories that include collaboration features such as pull requests, issue tracking, and peer reviews.
Repository managers distribute repositories across multiple locations on a user's workstation, providing redundant storage that allows for quick backup and recovery.
Q98. When Git Workflows contain a long-running branch, what purpose does the long-running branch serve?
Long-running branches store unstable code until it os peer reviewed for integration into a feature branch.
Long-running branches correspond to agile sprints and are used to store related to features developed in the sprint.
Long-running branches contain code related to experimental feature development that is merged into short-lived branches such as master.
Long-running branches correspond to different stages of development and are always open for topic/feature branches to be pulled into.
Note: master is not a short-lived branch, as answer "C" states. Answer "D" is the correct one.
Reference
Q99. What command takes changes from the master branch on the remote repository origin and merges then to the local checked-out branch?
git commit -u origin
git checkout origin
git pull origin master
git push origin master
Q100. 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.
Use the --atomic option with the push command.
Execute a pull, then resolve any merge conflicts and execute another push.
Execute a fetch, then execute another push.
Use the --force option with the push command.
Q101. What does the -p option add to the output of the git log command?
It adds patch output that shows the differences introduced in each commit.
It adds patch output that shows a summary listing modified files.
It adds padding to the output and displays a histogram showing the number of lines changed in each commit.
It adds the full commit message and notes associated with each commit.
Q102. What is the staging area or index?
an area that stores commits prior to them being pushed to the remote repository
an area containing stash entries that can applied to the working files
an area where changes from a branch in the remote repository are stored before they are applied to a local branch
an area that stores information about changes that will be included in the next commit
Q105. What type of Git hook could be used to validate that a commit message contains a ticket number?
pre-commit
commit-msg
applypatch-msg
prepare-commit-msg
Q106. What is the difference between git stash pop and git stash apply?
git stash pop pushes the topmost commit to the current branch, while git stash apply caches the last commit in the current branch.
git stash pop applies the topmost entry in the stash to the working files and removes it from the stash, while git stash apply applies the topmost entry in the stash to the working files but leaves it in the stash.
git stash pop merges the topmost commit to the current branch, while git stash apply merges the last commit in the current branch.
git stash pop applies the topmost entry in the stash to the working files but leaves it in the stash, while git stash apply applies the topmost entry in the stash to the working files and removes it from the stash.
Q107. 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?
git commit --verify
git notes show
git commit preview
git commit --dry-run
Q108. What statement best describes Git's concept of HEAD?
a pointer to the most recently changed file in the stage/index
a pointer to the master branch
a pointer to the most recent commit in the currently checked-out branch
a pointer to where the repository is stored in memory
Q109. 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?
git reset HEAD^ -- config.properties
git rm config.properties
git rf config.properties
git checkout HEAD -- config.properties
Q110. 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?
git grep -a "MaxConnections"
git log --search-string "MaxConnections"
git log -S "MaxConnections"
git commit --with "MaxConnections"
Q111. 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. What situation can occur when attempting to combine branches containing changes to the same piece of code?
lost code
automatic override
collisions
merge conflict
Q118. When Git workflows contain a topic branch, what purpose does the topic branch serve?
Topic branches store unstable code until it is peer reviewed for integration into another feature branch.
Topic branches correspond to different stages of development and are always open for long-running branches to be pulled into.
Topic branches are used in waterfall development methodologies to track the state of the code during the various stages of waterfall.
Topic branches are short-lived branches used to store work related to a particular feature.
Q119. What practice can help reduce the chances of encountering a merge conflict?
Provide detailed commit messages that describe the changes being introduced by the commit.
make large commits that introduce multiple features.
Keep local repository branches in sync with upstream branches in the remote repository by committing,pushing and pulling frequently.
Avoid frequent interaction with the remote repository to reduce the probability of pulling conflicts.
Q120. What command can you use to remove untracked files from the working directory?
git rm -all
git rm --cached
git clean -d -f
git checkout
Note: In Git, when multiple short options are used together, you can combine them into a single option by omitting the space between them. So, git clean -d -f can be combined as git clean -df.
Q121. 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?
⠀
git add doge.txt
git commit --amend --no-edit
⠀
git commit --amend --no-edit
⠀
git add doge.txt
git commit --patch --no-edit
⠀
git commit --patch --no-edit
Q122. Which command would remove a file named wrongfile from the current branch of a repository, the index, and working files?
Q123. What is the best way to report a bug to a GitHub project?
Send an email to a project owner.
I don't bother reporting software bugs because there's no transparency and they never get fixed anyway.
Search for the bug in the project's existing issues and create a new one if it hasn't been reported yet.
Use git search -diff to compare all commits in your repository history.
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.
Q124. 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?
Copy your branch changes and commit them directly to the main branch.
Create a pull request to merge your new branch into the main branch.
On second thought, maybe I won't share this fix. I'll just put it in my own private version of the source code.
Use git bisect to compare the buggy commit to an early commit that works as expected.
Explanation: Pull requests are the correct way to communicate that commits are ready for review and ultimate inclusion on the main branch.
Q128. _ will rewind your project to a specific point in time, losing all commits that came after it. _ will keep changes in those rewound commits as local modifications
git reset HEAD; git reset HEAD^
git reset --hard; git reset --soft
git reset --soft; git reset --hard
git rewind; git update
Q129. Explain the concept of "Git blame" and when it is used in a version control workflow.
Git blame is a command for finding and exposing the identity of contributors in a Git repository.
It's used for blaming others for code issues in a collaborative project.
Git blame is a feature for tracking the location of bugs in code.
Git blame is a tool for displaying who last modified each line of a file, helping to track changes and understand code history and authorship.
Q132. You're creating an action for the Github marketplace. why is it importance to create a release?
to alow you to create .zip files that you can easily share
to initiate a continuos integration process
to package your software so that it can become available through the Github marketplace
to create workflows and automate the process of generating software
Q133. You're looking at a repository page and click a folder name to open it. You have code search on, so you land in the code view. What is the quickest way to find a file on a path in your repo?
Press the slash(/) key and then the T key.
Go to advanced search.
From the search menu, select Path.
Press the T key.
Q134. How do you save a search that you use often using GitHub?
Click Save on the Search box.
Click Save in the advanced search menu.
Click Save on the search results page.
Bookmark the search results page.
Q135. which of these is not a label that github creates by default?
bug
documentation
wontfix
repo
Q136. What is the fastest way to start a search using Github web pages?
Press the slash(/) key on any page of the site.
Click the Search tab from the Github Version
Click the advanced Search link.
Click the search box and type your searc query.
Q137. Assigning an issue to a person implies that they ____.
will get a notification asking them to review the issue
are responsible for resolving the issue
are being informed of the issue's details
supervise the team resolving the issue
Q138. What does a Template repository do?
It creates a live demo of the current repository for training.
It allows you to create a default structure and files based on the current repository.
It lets you archive and store project settings.
It imports another project’s settings to the current project.
Q139. You’re creating an action for the GitHub Marketplace. Why is it important to create a release?
To allow you to create .zip files that you can easily share
To initiate a continuous integration process
To package your software so that it can become available through the Github Marketplace
To create workflows and automate the process of generating software
Q140. What are two ways to help Copilot give you more accurate suggestions?
Add instructions in parentheses.
Use shorthand, but accurate, descriptors.
Add context in comments.
Use concise variable names.
Use descriptive function names.
Q141. What is the main purpose of the Chat panel?
To search for answers in the current project’s repository
To chat with other developers who are working at your company
To have a conversational discussion with the AI behind Copilot
To get a list possible answers to a question
Q142. While doing a code review, you want to start an issue by highlighting a function that takes up several lines of code. What is the fastest way to do this in code view?
Click the first line number with the function, click the last line number to select a range, then in the hamburger menu select Reference in new issues
Copy the code and start a new issue, then use backticks around the function to create the issue
Select the function with the mouse, then right click and select reference in new issue
Click the line number with the function and select reference function in an issue
Q143. You’re reviewing a file in a repository and want to link to the current version of the file, even if it gets updated later. How can you achieve this?
Go to the Code tab and click Download zip
Right click the code text and select Permalink
Click Permalink on the code view
Copy the URL from the address bar
Q144. You’re organizing a desktop application project. You want to use an overview f your project statuses and be able to drag and drop issues. Which view would you use?
Board
Overview
Roadmap
Table
Q145. You’re in the repo for a specific project while working on an app module. You want to look for some of the docs you’ve been working on, which you wrote in markdown. To quickly look in your own repo for all files with a markdown extension, press the slash (/) button on the keyboard while on the repository page and type ___.
Path:.md
Grep:.md
Code:*.md
Ext:*.md
Q146. In GitHub Projects, how can you assign an issue to a collaborator?
Label the item with their username.
Select their username from the Assignees field.
Move the item to their column in the Boards view.
Add their handle in the comments.
Q147. Why should you include a descriptive function name when writing code with Copilot?
It helps Copilot add more variables to a function.
It trains the algorithm for the next time a GitHub client answers the question.
It helps Copilot have better context for code assistance and generation.
The function names are not fed to Copilot and are ignored by the AI.
Q148. You are working on a project that uses a Python library and you want to find an example of how to use a function across all public repositories. Which part of GitHub’s platform would you use?
Issues.
Discussions
Projects
Search
Q149. Working late on a project, you need to find an issue that was assigned to you. What query do you type?
Is:issue assignee:username
Is:issue user:username
Issue:issue user:username
assignee:username is:rep
Q150. you are working on an AI app and need to add information on project tables about the AI model being targeted. What feature allows you to do this?
Custom fields
Comments
Pull requests
Custom properties
Q151. What feature does the shortcut /table activate when used inside a GitHub comment section?
A data visualization table
A markdown table structure
An HTML table structure
A table of contents
Q152. How can you get better suggestions when creating functions?
Type “function” and then add a detailed and expressive function name.
Type “function” and then press Ctrl+/ (Windows) or Command +/ (Mac).
Include variables in the parentheses.
Use consistent formatting for your function names.
Q153. What does the RUN command do in a Dockerfile?
It allows you to specify which type of machine to procure.
It helps run your workflows.
It fires up an additional container
It allows you to execute a shell command during the image generation process