A developer wants to temporarily save changes without committing them to maintain a clean project history. What Git feature should they use?

  • git stash
  • git branch
  • git commit --amend
  • git tag
The correct option is a. git stash. This command allows the developer to save changes without committing them and revert the working directory to the last commit. It's useful for switching to a different branch or applying changes later. git branch is used to create, list, or delete branches. git commit --amend is used to modify the last commit, and git tag is used to create tags.

The git _______ command creates a new commit that undoes all of the changes made in a specified commit.

  • revert
  • reset
  • undo
  • backout
The correct option is revert. The git revert command is used to create a new commit that undoes the changes made in a previous commit, effectively reverting the repository's state to a previous point in time.

A git _______ is used to combine multiple commits into a single commit for a cleaner history.

  • merge
  • squash
  • combine
  • join
The correct option is squash. The git squash command is used during interactive rebase to combine multiple commits into a single commit. It helps in maintaining a cleaner and more readable commit history.

A developer discovers that confidential files were accidentally committed to a public Git repository. What steps should be taken to resolve this?

  • Identify and note down the commit hash. Use git reset or git revert to undo the commit.
  • Use git rm to remove the files from the repository, commit the changes, and push.
  • Create a new branch, cherry-pick the desired commits without the confidential files, and push.
  • Use git filter-branch to remove the files from the entire history and force push the updated repository.
Option 2 involves removing the confidential files and making a clean commit, ensuring that sensitive information is not exposed. Other options may have drawbacks or potential risks, such as force-pushing to a shared repository.

What is a Git Hook primarily used for?

  • Executing custom scripts
  • Managing branches
  • Resolving merge conflicts
  • Creating repositories
Git hooks are scripts that run automatically before or after specific Git events. They are primarily used for executing custom scripts, such as enforcing coding standards or triggering automated tests.

A DevOps team is implementing a new feature across different environments (development, testing, production). What Git strategy should they adopt to ensure smooth transitions and tracking?

  • Feature Branches
  • Git Tags
  • Forking
  • Rebasing
The DevOps team should adopt the strategy of using feature branches. Feature branches allow developers to work on new features or fixes independently in isolation. This helps in smooth transitions across different environments by merging the feature branch into each environment as needed. It also facilitates tracking changes related to specific features.

What advanced Git feature can be crucial for performance optimization in large-scale enterprise projects?

  • Git hooks
  • Git submodules
  • Git bisect
  • Git LFS (Large File Storage)
Git LFS is essential for managing large files in enterprise projects. It optimizes performance by efficiently handling and storing large assets, preventing them from slowing down the repository.

In complex workflows, pull requests may be used to merge changes from _______ branches to _______ branches before reaching the main branch.

  • feature, development, release, bugfix
  • topic, staging, master, hotfix
  • feature, release, master, hotfix
  • development, feature, master, bugfix
In complex workflows, pull requests are often utilized to merge changes from feature branches to development branches before reaching the main branch. This helps in organizing and reviewing changes before integration.

In the context of Git, what is a 'sparse checkout' and how does it improve performance with large repositories?

  • Sparse checkout is a feature that fetches only the latest commit, reducing repository size.
  • Sparse checkout is a mechanism for excluding specific files or directories during checkout.
  • Sparse checkout allows for parallel processing of Git commands, improving speed.
  • Sparse checkout reduces the number of contributors, streamlining performance.
A 'sparse checkout' in Git allows users to checkout only a subset of files or directories, reducing the size of the working directory. This is beneficial in large repositories, as it improves performance by excluding unnecessary files from the working directory.

What is the role of Git in Continuous Integration (CI) workflows?

  • Facilitates version control for collaborative development
  • Manages the build and deployment process
  • Monitors server performance during CI
  • Automates testing in the CI pipeline
Git provides version control, enabling collaboration among developers. While it's integral to CI, Git itself doesn't manage the CI workflow. CI involves automating builds, testing, and deployment, which is beyond Git's scope.