How can you revert a pushed commit in Git without losing history?

  • git reset
  • git revert
  • git rollback
  • git backout
To revert a pushed commit without losing history, use git revert. This command creates a new commit that undoes the changes introduced by the previous commit, preserving the commit history and avoiding force pushes.

Which Git hook would you use to run scripts before a commit is finalized?

  • pre-commit
  • post-commit
  • pre-push
  • post-receive
The pre-commit hook in Git is used to run scripts and checks before a commit is finalized, allowing developers to perform pre-commit validations.

In Git, _______ can be used to temporarily switch to another branch without committing the current work.

  • git checkout
  • git merge
  • git branch
  • git stash
In Git, the command 'git checkout' is used to switch between branches. It allows you to navigate between different branches without committing your current changes.

A developer frequently uses long and complex Git commands. Which feature of Git can they use to create shortcuts for these commands?

  • Git Alias
  • Git Tag
  • Git Remote
  • Git Branch
Git Alias is a feature that allows developers to create shortcuts for long and complex Git commands, enhancing efficiency and reducing the likelihood of errors in command execution.

What does the git log command display in a Git repository?

  • List of all branches.
  • Commit history with detailed information.
  • Uncommitted changes in the working directory.
  • Status of files in the staging area.
The git log command displays the commit history of the repository. It includes information such as the commit hash, author, date, and commit message. This helps in tracking changes, understanding the project's development timeline, and identifying specific commits for reference or debugging purposes.

To enhance security, sensitive data in a Git repository should be stored in an encrypted ________.

  • Blob
  • Object
  • File
  • Repository
Storing sensitive data in an encrypted object ensures that unauthorized users cannot access or view the confidential information, adding an extra layer of security to the Git repository.

To handle complex project structures in Git, large projects often rely on ________ to manage different components.

  • Branching
  • Submodules
  • Merging
  • Tags
In Git, submodules are used to manage different components of a project. Submodules allow you to include other Git repositories as a subdirectory, enabling better organization of complex project structures.

How do you resolve a merge conflict in Git?

  • git merge --abort
  • git resolve
  • git commit -m "Merge Conflict"
  • git merge --continue
When a merge conflict occurs in Git, the correct option is to use git merge --abort to abort the merge process and return to the pre-merge state. This option discards the current merge and lets you start over.

A common tool used in distributed teams for collaborative Git workflow management is git ________.

  • hub
  • flow
  • team
  • sync
Git hub is a command-line wrapper for Git that makes it easier to work with GitHub repositories. It provides additional features for collaborative workflows in distributed teams.

How does Git integration in an IDE enhance the coding process?

  • Streamlines collaboration with teammates
  • Enables syntax highlighting and code completion
  • Integrates with version control for tracking changes
  • Provides AI-based code suggestions
Git integration in IDEs primarily focuses on version control, allowing developers to track changes. It doesn't directly impact syntax highlighting or code suggestions, which are IDE-specific features.

The strategy of _______ involves integrating changes from the main branch frequently to minimize conflicts.

  • Rebase
  • Clone
  • Fork
  • Pull Request
The correct option is Rebase. Rebase is a strategy in Git that involves integrating changes from one branch into another by moving or combining a sequence of commits. It helps maintain a cleaner commit history and minimizes conflicts during integration.

In a distributed team, a developer needs to integrate a hotfix into multiple branches efficiently. What Git approach or feature should they use?

  • Git cherry-pick
  • Git merge --squash
  • Git rebase --onto
  • Git submodules
The Git approach that allows a developer to integrate a hotfix into multiple branches efficiently is Git cherry-pick. Cherry-pick enables the selection of specific commits and applies them to another branch, making it suitable for applying hotfixes to multiple branches without merging the entire branch.