In advanced Git hook usage, what is a practical application of a 'pre-receive' hook?

  • Enforcing commit message conventions
  • Running tests before accepting changes
  • Controlling access to the repository
  • Rejecting non-fast-forward pushes
The 'pre-receive' hook is often used to enforce server-side checks before accepting changes. This can include rejecting non-fast-forward pushes, ensuring commit message conventions, or running tests to maintain code quality. Understanding the practical applications of this hook is crucial for implementing advanced Git workflows and enforcing custom rules at the server level.

A DevOps pipeline often uses git _______ to trigger automated builds and tests.

  • COMMIT
  • PUSH
  • HOOKS
  • TAG
Git hooks are scripts that can be triggered at different points in the Git workflow. The post-receive hook, in particular, is commonly used in DevOps pipelines to initiate automated processes like builds and tests after receiving new code.

What is a Git alias?

  • A shortcut for a Git command
  • A unique identifier for a Git repository
  • A branch in a Git repository
  • A tool for creating Git repositories
A Git alias is a custom shortcut for a Git command. It allows users to create their own shorthand notation for frequently used Git commands, making the command-line interface more efficient and user-friendly. For example, you can create an alias 'co' for 'checkout' to save typing time.

A developer is working on a feature in a separate branch and needs to incorporate updates made in the main branch. What Git process should they use?

  • Merge
  • Rebase
  • Clone
  • Fetch
When working on a separate branch, using git rebase allows the developer to incorporate updates made in the main branch and apply their changes on top, resulting in a cleaner commit history.

A ________ is a pointer to a specific commit in Git.

  • Branch
  • Commit
  • Merge Conflict
  • Tag
A commit is a pointer to a specific state in the Git history. It represents a snapshot of the project at a specific point in time.

To streamline repetitive Git operations, a developer can use aliases like git co for checkout or git br for _______.

  • branch, browse, blame, branchlist
  • branchlist, browse, blame, browse
  • browse, branchlist, branch, blame
  • branchlist, browse, blame, branch
To streamline repetitive Git operations, a developer can use aliases like git co for checkout or git br for branching. This improves efficiency and reduces the likelihood of errors in commands.

When a merge conflict occurs, which section of the conflict markers indicates the changes from the current branch?

  • <<<<<<< HEAD
  • =======
  • >>>>>>> branch-name
  • <<<<<<< branch-name
The section <<<<<<< HEAD indicates the changes from the current branch in a merge conflict. Developers should edit the content between this marker and ======= to resolve conflicts manually.

How does Git store data?

  • Git stores data in a centralized database.
  • Git stores data in a distributed manner.
  • Git stores data in a local cache.
  • Git stores data in a relational database.
Git stores data in a distributed manner. Each user's local repository contains the entire history and data, making it highly efficient and capable of functioning independently even without a network connection.

How can you protect sensitive data from being committed in Git?

  • Use environment variables
  • Encrypt the entire repository
  • Add sensitive files to the .gitignore
  • Use the git secure command
To protect sensitive data from being committed, you should add the sensitive files or patterns to the .gitignore file. This ensures that Git ignores these files, preventing them from being included in the version control system and shared with others.

A team is facing an issue where a feature that previously worked is now broken. How can git bisect be used to identify the problematic commit?

  • Start the bisect using git bisect start and specify a good and bad commit. Git will automatically check out a commit between them. Run tests, and based on results, mark the commit as good or bad using git bisect good or git bisect bad.
  • Manually check out a commit, run tests, and mark the commit as good or bad using git bisect mark.
  • Use git bisect log to view the history and identify the problematic commit manually.
  • Execute git bisect run to automate the testing process and identify the faulty commit.
Option 1 correctly describes the process of using git bisect to systematically find the commit introducing the issue by marking commits as good or bad based on test results. Other options either involve manual methods or incorrect usage of git bisect.

How can you cherry-pick a commit from another branch into your current branch in Git?

  • git pick -c
  • git cherry-pick
  • git apply
  • git merge
The correct option is git cherry-pick . This command allows you to apply the changes introduced by the specified commit to your current branch. Cherry-picking is useful for selectively bringing in specific changes.

What is the difference in handling merge requests in GitLab versus pull requests in GitHub?

  • Terminology
  • Functionality
  • Repository hosting
  • Collaboration features
While both GitLab and GitHub facilitate code collaboration, understanding the terminology and functionality differences in handling merge requests (GitLab) and pull requests (GitHub) is essential. GitLab uses the term "merge request" while GitHub uses "pull request," and there are nuanced differences in how they handle code reviews, approvals, and merging changes into the main branch.