How does cherry-picking affect the commit history in Git?

  • It creates a new branch with the cherry-picked commit.
  • It rewrites the commit history by applying the changes of the selected commit.
  • It deletes the cherry-picked commit from the history.
  • It merges the cherry-picked commit into the current branch.
Cherry-picking involves selecting a specific commit and applying its changes onto the current branch. It essentially rewrites the commit history, maintaining the selected changes without merging the entire branch. This can be useful for incorporating specific features or bug fixes from one branch to another without merging the entire commit history.

What is a common challenge when migrating from a centralized version control system to Git?

  • Compatibility issues with existing repositories
  • Lack of branching and merging capabilities
  • Difficulty in learning Git commands
  • Limited support for large codebases
When migrating from a centralized VCS to Git, compatibility issues with existing repositories often arise. Git's distributed nature may pose challenges in adapting to a different workflow, and ensuring a smooth migration is crucial.

After a failed merge attempt, a developer needs to undo the merge to maintain project stability while resolving conflicts. What Git feature or command should they use?

  • git reset --hard HEAD
  • git revert HEAD
  • git checkout -b new-branch
  • git clean -df
The git reset --hard HEAD command is used to undo the last commit and return the repository to the state of the last successful merge. This allows the developer to start fresh and reattempt the merge while resolving conflicts. Other options like git revert and git clean have different purposes and do not address the need to undo the merge.

The technique of _______ in Git allows the separation of large binary files from the codebase, ideal for database backups.

  • cloning
  • stashing
  • LFS (Large File Storage)
  • purging
The technique of LFS (Large File Storage) in Git allows the separation of large binary files from the codebase, making it ideal for managing database backups and other large assets. Git LFS replaces large files with text pointers, reducing the overall repository size and improving performance. This is particularly beneficial when dealing with large binary files commonly found in database backups.

In Git, what does the 'master' branch represent by default?

  • The main development branch
  • A branch for experimental changes
  • A branch for emergency fixes
  • A backup branch
By default, the 'master' branch in Git represents the main development branch. It is the default branch that is created when you initialize a new Git repository. Developers often use this branch for ongoing development and feature integration.

To change the commit message of the most recent commit, use the command git commit --_______.

  • amend
  • edit
  • modify
  • change
The correct option is amend. The git commit --amend command allows you to modify the most recent commit message. It opens the default text editor for you to make changes. This is useful when you need to fix a typo or provide additional information to the commit message without creating a new commit.

Which Git command is typically used to upload your local repository to a cloud platform?

  • git push
  • git commit
  • git pull
  • git merge
The 'git push' command is used to upload the local repository to a remote repository on a cloud platform. It sends local changes to the remote repository, keeping them in sync.

When would you use git checkout instead of git reset to undo changes?

  • git checkout is used for switching branches
  • git checkout discards changes in the working directory
  • git reset is used for switching branches
  • git reset discards changes in the working directory
The correct option is git checkout. It is used to discard changes in the working directory by replacing them with the last committed version. On the other hand, git reset is more commonly used for moving the branch pointer and can be more powerful, potentially discarding commits. git checkout is a safer option for simply undoing changes in the working directory.

In complex projects, maintaining a clean history can involve the use of git rebase -i, which stands for interactive ________.

  • iteration
  • interface
  • indexing
  • rebase
The correct option is (d) rebase. The command git rebase -i allows for interactive rebasing, providing a powerful interface to modify commit history. This is particularly useful for rearranging, editing, or combining commits to maintain a cleaner project history.

How does Git handle code reviews differently from traditional version control systems?

  • Integrated code review tools
  • Manual code reviews through email
  • No support for code reviews
  • Automatic code reviews during commit
Git integrates code review tools directly into the workflow. This allows for seamless collaboration, with developers able to comment on specific lines of code, suggest changes, and ensure code quality before merging.