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.

For complex project histories, the git ________ command is essential to filter and modify historical commits during migration.

  • filter
  • amend
  • rebase
  • cherry-pick
The rebase command is used to filter and modify historical commits during migration, allowing for a more organized and streamlined project history. This is crucial for complex project timelines.

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.

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.

How does the 'pre-receive' Git Hook differ from the 'post-receive' Hook?

  • They both trigger before and after receiving data
  • 'pre-receive' runs before updates are accepted, and 'post-receive' runs after updates are accepted
  • 'pre-receive' runs after updates are accepted, and 'post-receive' runs before updates are accepted
  • 'pre-receive' runs only for specific branches, 'post-receive' runs for all branches
The 'pre-receive' hook is invoked before any references are updated, allowing rejection of updates. In contrast, 'post-receive' is invoked after all refs have been updated, making it useful for triggering actions after the update. Understanding their timing is crucial for implementing custom Git workflows.

In a complex project workflow, a __________ Git hook can enforce commit message standards.

  • Pre-commit
  • Post-commit
  • Pre-push
  • Post-merge
In a complex project, a "Pre-commit" Git hook can be set up to enforce commit message standards before the actual commit is made. This ensures consistency in commit messages and helps maintain a clean commit history.

Cloud platforms like GitHub provide _________ to facilitate tracking issues and tasks related to the codebase.

  • Wiki
  • Issue Tracker
  • Repository
  • Pull Request
GitHub's issue tracker is a powerful tool for tracking bugs, enhancements, and tasks associated with a codebase. It allows collaboration and discussion on specific topics.

During a critical hotfix, a developer has uncommitted changes that are not ready for commit. How should they use Git stash to handle this situation?

  • git stash apply
  • git stash drop
  • git stash save and git stash pop
  • git stash save and git stash apply
The developer should use git stash save to save their changes and then git stash apply to reapply them after the hotfix. This ensures that their uncommitted changes are stored safely and can be easily restored without affecting the ongoing hotfix.