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.
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.
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.
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.
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.
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.
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 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.
To automate builds after every commit, a hook in Git known as git _______ can be used.
- pre-commit
- post-commit
- pre-build
- post-build
In Git, the post-commit hook is used to automate actions after each commit. This hook is useful for tasks like triggering build processes.
git _______ can be used to combine the changes made on two different branches without creating a new commit.
- merge
- squash
- rebase
- commit
Git rebase allows you to incorporate changes from one branch into another by applying each commit on the branch to the target branch. Unlike merge, it allows for a cleaner commit history by avoiding unnecessary merge commits.