A developer accidentally committed a file that should not be tracked by Git. What command should they use to rectify this before pushing?

  • git reset HEAD
  • git rm --cached
  • git checkout -- filename
  • git revert
The correct option is c. git checkout -- filename. This command discards changes in the working directory and unstages the file, effectively "uncommitting" it. git reset HEAD and git rm --cached are used for different purposes. git reset HEAD unstages changes, and git rm --cached unstages the file but also stages the removal. git revert is used to create a new commit that undoes a previous commit.

In what scenario might you use a git filter-branch?

  • Restructuring the commit history
  • Updating remote branches
  • Resolving merge conflicts
  • Renaming a local branch
The git filter-branch command is used to rewrite, restructure, or filter the commit history. It can be useful when you need to make substantial changes to the history, such as removing sensitive information or restructuring the commit tree.

To fix broken references in Git, the _______ command can be used to recover lost commits and branches.

  • git recover
  • git fsck
  • git repair
  • git fix
The correct option is git fsck. This command is used to perform a file system check on the Git repository and can help recover lost commits and branches by fixing broken references.

After making several commits, a developer realizes they need to combine these commits into a single commit. What Git process should they follow?

  • Use "git merge" to combine the commits
  • Use "git squash" to merge the commits into a single commit
  • Use "git combine" to merge the commits
  • Use "git rebase" to combine the commits
The correct option is to use "git rebase" to combine the commits into a single commit. Rebase allows the developer to reapply commits on top of another base commit, effectively combining them into a single commit. Squash is used during interactive rebase to merge commits.

In a situation where multiple teams are working on different features simultaneously, how should merge conflicts be addressed to maintain a stable main branch?

  • Prioritize conflicts based on team seniority
  • Use feature branches and conduct regular merges to main
  • Delay conflict resolution until the end of the project
  • Create a separate unstable branch for each team
Using feature branches and regularly merging them into the main branch helps detect and resolve conflicts early. It ensures that the main branch remains stable, as conflicts are addressed incrementally. Options 1, 3, and 4 suggest approaches that are not recommended for maintaining a stable main branch in a collaborative environment.

What are the implications of using git rebase in a collaborative environment?

  • It simplifies collaboration
  • It makes collaboration complex
  • It preserves the commit history
  • It discards commit history
Git rebase rewrites commit history, which can lead to conflicts for collaborators who have already pulled the changes. It's important to use it carefully in a shared repository to avoid disrupting others' work.

What is the purpose of the git bisect command in debugging?

  • Efficiently find the commit introducing a bug
  • Merge branches in Git
  • Rewrite commit history
  • View differences between branches
The git bisect command is used for binary search through commit history, helping identify the specific commit that introduced a bug by efficiently narrowing down the range of potentially faulty commits.

To undo changes made to your working directory, use the command git _______.

  • reset
  • revert
  • restore
  • rollback
The correct option is "b) revert." The git revert command is used to undo changes made in the working directory by creating a new commit that undoes the specified commit. This allows you to maintain a linear project history.

GitLab’s CI/CD pipelines can be configured through a file named _________.

  • .gitlab-pipeline.yml
  • .gitlab-ci.yml
  • .gitlab-pipe.yml
  • .gitlab-config.yml
The .gitlab-ci.yml file is used to define CI/CD pipelines in GitLab. It specifies the steps and actions to be taken during the pipeline execution, such as building, testing, and deploying.

To handle large files during a Git transition, the use of git _______ can be a solution.

  • annex
  • bigfile
  • lfs
  • compress
The correct option is 'lfs.' In Git, Large File Storage (LFS) is a system designed to handle large files efficiently. By using the 'git lfs' command, large files can be managed separately, preventing them from bloating the repository and slowing down the version control system.