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.
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.
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.
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.
In Git, a release is often marked with a ________, representing a stable point in the development.
- Tag
- Stash
- Branch
- Commit
In Git, a release is commonly marked with a tag. Tags are labels for specific points in Git history, often used to represent stable versions of the software.
What is the main benefit of conducting code reviews before merging changes?
- Identifying and fixing bugs and issues early in the development process.
- Speeding up the merging process without thorough examination.
- Adding unnecessary complexity to the codebase.
- Code reviews are optional and don't impact the development workflow.
Code reviews help in early bug detection and ensure that the proposed changes meet coding standards. They contribute to better code quality, knowledge sharing among team members, and overall project maintainability.
How does a lightweight tag in Git differ from an annotated tag?
- Contains only a reference to a commit
- Includes additional information like a message
- Points to a branch
- Represents a merge commit
A lightweight tag in Git only contains a reference to a specific commit, while an annotated tag includes additional information such as a tagger name, email, date, and a tagging message. Annotated tags are recommended for important releases or milestones.
Describe the role of 'feature branches' in Git's branching model.
- Long-lived branches for ongoing features
- Temporary branches for hotfixes
- Branches for experimental changes
- Short-lived branches for documentation
'Feature branches' are long-lived branches created for ongoing features or tasks. They allow developers to work on features independently and then integrate them back into the main branch when ready. This promotes a clean and organized development process.
_________ in Git can be automated in an IDE to ensure code quality before commits.
- Code Signing
- Code Linting
- Code Obfuscation
- Code Encryption
Code linting in Git can be automated in an IDE to ensure code quality before commits. Linting checks the code for potential errors, stylistic issues, and adherence to coding standards, helping developers catch and fix issues early in the development process.
The command git _______ is used to clone a remote repository to your local machine.
- pull
- fetch
- clone
- push
The git clone command is used to clone a remote repository to your local machine. It copies the entire repository, including all branches and commit history, to your local system.
How can you find a commit in the Git history that introduced a bug using the git bisect command?
- git log -S
- git bisect start
- git blame
- git revert
The correct option is B. git bisect start is used to perform a binary search through the commit history, helping identify the commit that introduced a bug. The bisect command automates the process of checking out different commits until the problematic one is found.
Your team is reviewing a complex set of changes. How can you use Git to navigate through each change individually to discuss them?
- git log -p
- git diff
- git blame
- git bisect
To navigate through each change individually and discuss them, you can use git log -p to show the commit history with the associated changes. git diff shows the changes in the working directory, but it's not specific to individual commits. git blame is used to show changes in a file, and git bisect is used for binary search to find a specific commit causing an issue.