A new branch in Git can be created and switched to using the git _______ command.
- branch
- checkout
- merge
- commit
The 'git checkout' command is used to switch branches in Git. This command is also used to create a new branch and switch to it. The correct option is 'checkout'.
What are the implications of squashing commits when merging a feature branch into the main branch?
- Preserve individual commit history
- Combine multiple commits into one
- Increase repository size
- Create conflicts in the main branch
Squashing commits combines multiple commits into a single commit, providing a cleaner history. It helps maintain a more organized and readable history but can result in the loss of individual commit details.
The command git _______ is used to integrate changes from one branch to another.
- Checkout
- Merge
- Pull
- Push
The command git **merge** is used to integrate changes from one branch to another in Git. It combines changes from different branches.
A developer finds that some commits are missing from the Git history, suggesting a corrupted repository. What steps should they take to investigate and restore the repository?
- Use the git fsck command to check for object integrity and attempt to recover the missing commits.
- Clone a fresh copy of the repository from a backup.
- Delete the local repository and create a new one to start fresh.
- Run git blame on affected files to identify the missing commits and manually reapply them.
The git fsck command is used to check the integrity of objects in the Git database. Running this command can help identify and potentially recover missing commits. Restoring from a backup or recreating the repository may lead to data loss, making git fsck a more appropriate first step.
What is the role of Git hooks in securing a repository?
- Customizing pre-commit actions
- Implementing access control
- Enforcing coding standards
- Automating deployment
Git hooks are scripts that run automatically before or after events in Git. By implementing access control in hooks, you can secure the repository by controlling who can push changes and under what conditions.
What are the implications of force pushing (git push --force) in a collaborative Git repository?
- It's a standard push operation
- It overwrites the remote branch with local changes
- It creates a new branch remotely
- It prompts collaborators for approval
Force pushing overwrites the remote branch with local changes, potentially causing conflicts for collaborators. It should be used cautiously to avoid disrupting others' work.
To handle large codebases in enterprise environments, Git can be integrated with ________ for enhanced performance.
- Jenkins
- Docker
- Bitbucket
- GitLab
Git can be integrated with Docker for enhanced performance in handling large codebases. Docker provides containerization, allowing consistent environments across different stages of the development lifecycle. This integration aids in efficient deployment and scalability.
What command is used to start a new branch in Git?
- git branch
- git init
- git new-branch
- git checkout -b
The 'git checkout -b' command is used to create and switch to a new branch in one step. It is a convenient shortcut for creating feature branches.
In C++, passing large structures or classes to functions is typically done by _______ to avoid expensive copy operations.
- pointers
- value
- integers
- operators
Passing large structures or classes by value results in copy operations, which can be expensive in terms of performance. To mitigate this, C++ developers often pass large data structures using pointers or references, allowing the function to access the original data without copying.
git _______ is used to view the specific changes introduced in a commit.
- log
- show
- diff
- inspect
The correct option is "c) diff." The git diff command is used to show the changes between the working directory and the specified commit. It provides a line-by-line comparison of what was added, modified, or deleted.