Skip to content

Commit

Permalink
added reference-git-quiz.md (#6154)
Browse files Browse the repository at this point in the history
added references

Co-authored-by: Evgenii Bazhanov <evg.bazhanov@yahoo.com>
  • Loading branch information
saher2106 and Ebazhanov authored Oct 4, 2023
1 parent ba4c0bd commit fce02b4
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions git/git-quiz.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
[Reference](https://www.howtogeek.com/759319/how-to-check-and-update-your-git-version/)


[Reference](https://www.howtogeek.com/759319/how-to-check-and-update-your-git-version/)

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

- [ ] git remote add new
Expand All @@ -35,6 +37,8 @@ git merge --squash HEAD@{1}
- `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.

[Reference](https://stackoverflow.com/questions/70962338/documentation-of-default-target-of-git-merge-squash)

#### 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
Expand All @@ -53,8 +57,8 @@ git merge --squash HEAD@{1}
- [ ] All new files are staged
- [ ] Only updated files are staged

[Reference](https://www.geeksforgeeks.org/difference-between-git-add-a-and-git-add/)

- [Reference](https://git-scm.com/docs/git-add)
- [Reference](https://www.geeksforgeeks.org/difference-between-git-add-a-and-git-add/)

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

Expand All @@ -65,7 +69,8 @@ git merge --squash HEAD@{1}
- [ ] An inline editor for modifying remote repositories
- [ ] The last 5 git versions you've installed

[Reference](https://www.javatpoint.com/git-remote)
- [Reference](https://git-scm.com/docs/git-remote)
- [Reference](https://www.javatpoint.com/git-remote)

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

Expand All @@ -80,6 +85,8 @@ git cherry-pick kj2342134sdf090093f0sdgasdf99sdfo992mmmf9921231
- [ ] 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.

[Reference](https://git-scm.com/docs/git-cherry-pick)

Explanation:

'git checkout feature-user-location' switches to the 'feature-user-location' branch.
Expand All @@ -95,7 +102,8 @@ So, this sequence of commands is cherry-picking a specific commit onto the featu
- [ ] It keeps the HEAD at the current commit, but clears all previous commits.
- [x] It sets HEAD to the previous commit and leaves changes from the undone commit in the stage/index.

[Reference](https://stackoverflow.com/questions/24568936/what-is-difference-between-git-reset-hard-head1-and-git-reset-soft-head)
- [Reference](https://git-scm.com/docs/git-reset)
- [Reference](https://stackoverflow.com/questions/24568936/what-is-difference-between-git-reset-hard-head1-and-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?

Expand All @@ -104,7 +112,8 @@ So, this sequence of commands is cherry-picking a specific commit onto the featu
- [ ] Run a git rebase to find the buggy commit.
- [x] Use git bisect to compare the buggy commit to an early commit that works as expected.

[Reference](https://stackoverflow.com/questions/69552866/how-to-diagnose-a-problem-in-git-commit-history)
- [Reference](https://git-scm.com/docs/git-bisect)
- [Reference](https://stackoverflow.com/questions/69552866/how-to-diagnose-a-problem-in-git-commit-history)

#### Q10. Why would the following command be used?

Expand All @@ -115,7 +124,8 @@ So, this sequence of commands is cherry-picking a specific commit onto the featu
- [ ] To delete the last 10 commits and reset the HEAD
- [ ] In order to locally cache the last 10 commits

[Reference](https://stackoverflow.com/questions/363908/how-do-i-use-git-rebase-i-to-rebase-all-changes-in-a-branch)
- [Reference](https://git-scm.com/docs/git-rebase#_interactive_mode)
- [Reference](https://stackoverflow.com/questions/363908/how-do-i-use-git-rebase-i-to-rebase-all-changes-in-a-branch)

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

Expand All @@ -124,7 +134,8 @@ So, this sequence of commands is cherry-picking a specific commit onto the featu
- [ ] To fire a script after updates are made to the remote repository
- [ ] To debug all commit tags and release versions

[Reference](https://docs.github.com/en/enterprise-server@3.10/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/working-with-pre-receive-hooks)
- [Reference](https://git-scm.com/docs/githooks)
- [Reference](https://docs.github.com/en/enterprise-server@3.10/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/working-with-pre-receive-hooks)

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

Expand All @@ -133,7 +144,8 @@ So, this sequence of commands is cherry-picking a specific commit onto the featu
- [x] `--global`
- [ ] `--update`

[Reference](https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration)
- [Reference](https://git-scm.com/docs/git-config)
- [Reference](https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration)

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

Expand All @@ -142,7 +154,8 @@ So, this sequence of commands is cherry-picking a specific commit onto the featu
- [x] Rebasing
- [ ] Reflogging

[Reference](https://stackoverflow.com/questions/31409736/squash-commits-directly-on-feature-without-rebase-or-merge)
- [Reference](https://git-scm.com/docs/git-rebase#_interactive_mode)
- [Reference](https://stackoverflow.com/questions/31409736/squash-commits-directly-on-feature-without-rebase-or-merge)

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

Expand All @@ -151,7 +164,8 @@ So, this sequence of commands is cherry-picking a specific commit onto the featu
- [ ] Nothing, cloning is not a supported git function
- [ ] A copy of the repository would be created on the hosting platform

[Reference](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)
- [Reference](https://git-scm.com/docs/git-clone)
- [Reference](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)

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

Expand All @@ -160,7 +174,8 @@ So, this sequence of commands is cherry-picking a specific commit onto the featu
- [ ] Run `git commit --info` with the commit hash.
- [ ] Access the commit stash data with `git stash`.

[Reference](https://stackoverflow.com/questions/424071/how-do-i-list-all-the-files-in-a-commit#:~:text=If%20you%20want%20to%20get%20the%20list%20of,you%20can%20use%20git%20ls-tree%20--name-only%20-r%20%3Ccommit-ish%3E)
- [Reference](https://git-scm.com/docs/git-diff-tree)
- [Reference](https://stackoverflow.com/questions/424071/how-do-i-list-all-the-files-in-a-commit#:~:text=If%20you%20want%20to%20get%20the%20list%20of,you%20can%20use%20git%20ls-tree%20--name-only%20-r%20%3Ccommit-ish%3E)

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

Expand All @@ -177,6 +192,8 @@ build/
- [x] All files in the build directory, as well as files ending with .txt or .metadata
- [ ] Only files with .swift and .txt extensions.

[Reference](https://git-scm.com/docs/gitignore)

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?
Expand Down Expand Up @@ -289,6 +306,8 @@ git bisect good 69faab6268350295550de7d587bc323d
- [x] Squash the related commits together into a single coherent commit.
- [ ] Stash the related commits under a new hash.

[Reference](https://git-scm.com/docs/git-rebase#_interactive_mode)

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

**Note:** Which statement is true of the `git push` command?
Expand All @@ -311,13 +330,17 @@ git push -u origin master
- [ ] Same as before, git push -u origin master
- [x] git push

[Reference](https://git-scm.com/docs/git-push)

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

- [ ] Run `git hotfix` with the shortcut name.
- [ ] Assign a shortcut or command using git options file.
- [ ] Use the `git custom-key` command.
- [x] Create an alias using the `git config` command.

[Reference](https://git-scm.com/docs/git-config)

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

```shell
Expand Down

0 comments on commit fce02b4

Please sign in to comment.