What are the best practices for garbage collection in Git to optimize repository performance?
- Perform git gc regularly
- Use git prune to remove unreachable objects
- Utilize git repack to optimize storage
- Apply git fsck to check repository integrity
Garbage collection in Git helps optimize the repository's performance by compressing and organizing objects. git repack is an advanced strategy that combines objects, optimizing storage and improving performance.
An enterprise is experiencing slow performance with their Git repositories due to large file sizes. What Git feature should they consider implementing?
- Git LFS (Large File Storage)
- Git Submodules
- Git Stash
- Git Clone
In scenarios where large files impact Git repository performance, Git LFS (Large File Storage) is a recommended solution. It allows the storage of large files outside the regular Git repository, improving overall performance by handling large files more efficiently.
What does the git log command display in a Git repository?
- List of all branches.
- Commit history with detailed information.
- Uncommitted changes in the working directory.
- Status of files in the staging area.
The git log command displays the commit history of the repository. It includes information such as the commit hash, author, date, and commit message. This helps in tracking changes, understanding the project's development timeline, and identifying specific commits for reference or debugging purposes.
A developer frequently uses long and complex Git commands. Which feature of Git can they use to create shortcuts for these commands?
- Git Alias
- Git Tag
- Git Remote
- Git Branch
Git Alias is a feature that allows developers to create shortcuts for long and complex Git commands, enhancing efficiency and reducing the likelihood of errors in command execution.
In Git, _______ can be used to temporarily switch to another branch without committing the current work.
- git checkout
- git merge
- git branch
- git stash
In Git, the command 'git checkout' is used to switch between branches. It allows you to navigate between different branches without committing your current changes.
Which Git hook would you use to run scripts before a commit is finalized?
- pre-commit
- post-commit
- pre-push
- post-receive
The pre-commit hook in Git is used to run scripts and checks before a commit is finalized, allowing developers to perform pre-commit validations.
How can you revert a pushed commit in Git without losing history?
- git reset
- git revert
- git rollback
- git backout
To revert a pushed commit without losing history, use git revert. This command creates a new commit that undoes the changes introduced by the previous commit, preserving the commit history and avoiding force pushes.
How can you identify the specific commits that introduced conflicting changes during a merge in Git?
- git blame
- git show
- git diff
- git log
When a merge conflict occurs, using git diff will help identify the conflicting changes introduced by specific commits. This command shows the differences between the working directory and the index or a tree, making it useful for inspecting changes.
In Git, a _______ merge is used to integrate changes from one branch into another without creating a merge commit.
- Fast-Forward
- Squash
- Recursive
- Cherry-pick
The correct option is Fast-Forward. A Fast-Forward merge in Git is used to integrate changes from one branch into another when there are no new changes on the target branch. It performs a simple "move forward" of the branch pointer, avoiding the creation of a merge commit.
Changing the history of public branches is generally discouraged because it can lead to ________ for other collaborators.
- synchronization issues
- confusion
- conflict resolution
- frustration
The correct option is (c) conflict resolution. Altering the history of public branches can create conflicts for other collaborators, making it challenging to resolve differences in the repository. It's a good practice to avoid history changes on shared branches.