How does adding files to .gitignore affect existing tracked files in Git?

  • Tracked files are immediately untracked and removed from the repository.
  • Tracked files remain, but changes to them are no longer tracked.
  • Tracked files are ignored only for the current commit.
  • Tracked files are deleted from the working directory, but not the repository.
When files are added to .gitignore, it only affects untracked files. Existing tracked files remain in the repository, and their changes are still tracked unless committed before the addition to .gitignore.

What is the process for recovering a Git repository if the .git directory is accidentally deleted or corrupted?

  • git recover
  • git restore
  • git clone
  • git init
The correct process is to use git clone to create a new copy of the repository from a remote or another existing repository. This will recover the repository, including its history and branches.

A development team is implementing a code quality tool into their Git workflow. They need to automatically reject commits that don't meet the quality standards. Which Git feature should they leverage?

  • Git Hooks
  • Git Stash
  • Git Bisect
  • Git Reflog
Git Hooks are scripts triggered by Git events, allowing the team to enforce code quality standards by rejecting commits that don't meet criteria.

The git ______ command is used to switch branches or restore working tree files.

  • checkout
  • switch
  • restore
  • branch
The correct option is "checkout." The git checkout command in Git is versatile and can be used for various purposes, including switching branches and restoring working tree files. For example, git checkout switches to the specified branch.

How can you view the changes introduced in a specific commit using Git?

  • git show
  • git diff
  • git log -p
  • git log --oneline
To view the changes introduced in a specific commit, you can use git show . This command displays the details of the commit, including the changes made.

What is a Git hook?

  • A script that runs before or after events
  • A branch in Git
  • A Git repository
  • A command to undo the last commit
A Git hook is a script that runs automatically before or after certain Git events, such as committing or merging. It allows developers to customize and automate processes in response to specific actions in the Git workflow.

After performing a rebase, you may need to use git ______ to incorporate the changes into the base branch.

  • apply
  • merge
  • commit
  • pull
After performing a rebase, you can use git apply to incorporate the changes into the base branch. This step is necessary to complete the rebase process and update the branch with the rebased changes.

When merging branches, which Git command is used to create a new commit that represents the combined changes?

  • git push
  • git commit
  • git merge
  • git branch
The correct command for merging branches and creating a new commit is git merge. This command combines the changes from different branches into the current branch, resulting in a new commit that represents the merged state.

A team working on a project hosted on GitHub wants to ensure code style consistency. Which feature should they implement?

  • Git Hooks
  • Git Submodules
  • Git LFS
  • Git Tags
To ensure code style consistency in a project hosted on GitHub, the team should implement Git Hooks. Git Hooks allow developers to run custom scripts before or after certain Git events, enabling them to enforce coding standards and other practices.

What is a common strategy for managing releases in the Gitflow model?

  • Creating a hotfix branch directly from the main branch to address critical issues in the released version.
  • Merging all feature branches into the main branch and tagging the commit for release.
  • Creating a separate branch for each feature, bug fix, and release, maintaining a stable main branch.
  • Skipping the release branch and merging feature branches directly into production.
In Gitflow, a release branch is created to prepare for a new release. It involves bug fixes, documentation updates, and version number increments. Once ready, it's merged into both the main and develop branches.