Which Git feature is commonly used to trigger a CI/CD pipeline?
- Git Hooks
- Git Stash
- Git Submodules
- Git Branches
Git Hooks are scripts triggered by specific Git events, making them suitable for CI/CD pipeline triggers. Stash, submodules, and branches serve different purposes in Git but are not directly tied to CI/CD.
After reviewing a repository's history, a team leader finds an unauthorized access. What Git practice could have prevented this?
- Branch protection
- Code signing
- Git hooks
- Commit squashing
Branch protection can prevent unauthorized access by defining rules that restrict certain actions on specific branches. By enforcing access controls, the team leader could have prevented unauthorized changes and maintained a secure repository.
What is the purpose of the git commit command?
- Save changes to the local repository
- Upload changes to the remote repository
- Discard local changes
- Create a new branch
The purpose of the git commit command is to save changes to the local repository. It creates a new commit with the changes you have made, providing a way to track the history of your project.
To ignore certain files from being tracked in Git, list them in a _______ file.
- .exclude
- .gitignore
- exclude.txt
- ignorefile
The correct option is "b) .gitignore." The .gitignore file is used to specify files or patterns that Git should ignore. This helps in preventing unnecessary files from being tracked, such as temporary files or compiled binaries.
A team member needs to review changes made in the past two weeks, but there are too many commits to check individually. What Git command should they use?
- git log --since="2 weeks ago"
- git show --last=2.weeks
- git diff --since="2 weeks ago"
- git blame --since="2 weeks ago"
The correct option is to use "git log --since="2 weeks ago"" to view the commit history for the past two weeks. Git log provides a detailed overview of commits, making it easier for the team member to review changes over the specified period.
In an open source project, a critical bug is discovered in a release. How should the maintainers use Git to address this issue promptly while maintaining the integrity of the project?
- Cherry-pick
- Revert
- Reset
- Squash
The maintainers should use the "Revert" option. Reverting creates a new commit that undoes the changes introduced by a specific commit, effectively addressing the critical bug while maintaining the integrity of the project history. It is a safer option than resetting or squashing, as it keeps a clear record of the fix without altering existing commits.
Customizing the __________ Hook can help enforce coding standards before code is pushed.
- Pre-push
- Pre-receive
- Post-commit
- Post-receive
The correct option is Pre-receive. This hook is executed on the server when you receive a push. Customizing it allows you to enforce coding standards before accepting the pushed code.
A developer wants to automate the deployment of their application to a server after each commit to the master branch on GitLab. Which Git feature should they utilize?
- GitLab CI/CD
- Git Submodules
- Git Merge Requests
- Git Stash
To automate the deployment process after each commit to the master branch on GitLab, the developer should utilize GitLab CI/CD (Continuous Integration/Continuous Deployment). GitLab CI/CD allows developers to define and automate pipelines for building, testing, and deploying their applications.
What is the command to list all the tags in a Git repository?
- git show-tags
- git tags
- git list-tags
- git tag -l
The correct option is git tag -l. This command lists all the tags in the Git repository. It's essential for getting an overview of available tags, especially in larger projects with numerous releases.
In the context of a large project, how does Git facilitate code reviews and quality assurance?
- Branching and pull requests for isolated code reviews
- Integration with automated testing tools
- Detailed commit history and blame feature
- Linear versioning history
Git facilitates code reviews and quality assurance in large projects through features like branching and pull requests, which enable isolated code reviews. Additionally, it integrates seamlessly with automated testing tools and provides a detailed commit history and blame feature.