What is the purpose of a .gitignore file in a Git repository?
- Specifies files and directories that should be ignored by Git.
- Lists all files in the repository.
- Tracks changes in the repository.
- Adds new files to the repository.
The .gitignore file is used to specify intentionally untracked files that Git should ignore. This is useful for excluding files generated by the build process or system files that should not be committed. It helps in maintaining a clean repository by avoiding the accidental addition of irrelevant files.
When resolving conflicts, the git _______ command allows a user to navigate through conflicted files.
- Resolve
- Merge
- Diff
- Checkout
The correct option is Checkout. The git Checkout command in the context of conflict resolution allows a user to navigate through conflicted files. It helps in selecting the desired changes and resolving conflicts during the merge process.
In the context of enterprise, what is a key benefit of implementing Git LFS (Large File Storage)?
- Improved Version Control for Large Files
- Faster Commit and Push Operations
- Enhanced Collaboration on Small Files
- Reduced Storage Costs for Small Repositories
Git LFS provides better version control for large files, making it suitable for enterprises dealing with multimedia assets like images and videos. It doesn't significantly impact small files or storage costs for smaller repositories.
In managing open source projects with Git, the ________ file is crucial for describing project guidelines and contribution procedures.
- README
- LICENSE
- CONTRIBUTING
- CODEOWNERS
The CONTRIBUTING file in a Git repository is essential for providing guidelines on how developers can contribute to the project. It outlines coding standards, processes for submitting issues or pull requests, and other contribution-related information.
To automate the execution of tests every time a new commit is pushed, a _________ Git hook can be utilized.
- Pre-receive
- Post-receive
- Update
- Pre-commit
Git hooks are scripts that Git executes before or after events such as commit, push, and receive. The Post-receive hook is suitable for automated tasks after a successful push.
In a collaborative project using Git, what is the purpose of a pull request?
- A pull request is a mechanism for contributors to propose changes to the main repository and request that someone review and merge their changes.
- Pull requests are used to fetch changes from a remote repository.
- Pull requests are only necessary in Forking workflow, not in Feature Branch workflow.
- Pull requests are equivalent to merge requests and are used only for merging code.
Pull requests facilitate code review, discussion, and automated testing before changes are merged into the main branch, promoting collaboration and maintaining code quality.
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.