Cloud platforms like GitHub provide _________ to facilitate tracking issues and tasks related to the codebase.
- Wiki
- Issue Tracker
- Repository
- Pull Request
GitHub's issue tracker is a powerful tool for tracking bugs, enhancements, and tasks associated with a codebase. It allows collaboration and discussion on specific topics.
During a critical hotfix, a developer has uncommitted changes that are not ready for commit. How should they use Git stash to handle this situation?
- git stash apply
- git stash drop
- git stash save and git stash pop
- git stash save and git stash apply
The developer should use git stash save to save their changes and then git stash apply to reapply them after the hotfix. This ensures that their uncommitted changes are stored safely and can be easily restored without affecting the ongoing hotfix.
To change the commit message of the most recent commit, use the command git commit --_______.
- amend
- edit
- modify
- change
The correct option is amend. The git commit --amend command allows you to modify the most recent commit message. It opens the default text editor for you to make changes. This is useful when you need to fix a typo or provide additional information to the commit message without creating a new commit.
Which Git command is typically used to upload your local repository to a cloud platform?
- git push
- git commit
- git pull
- git merge
The 'git push' command is used to upload the local repository to a remote repository on a cloud platform. It sends local changes to the remote repository, keeping them in sync.
When would you use git checkout instead of git reset to undo changes?
- git checkout is used for switching branches
- git checkout discards changes in the working directory
- git reset is used for switching branches
- git reset discards changes in the working directory
The correct option is git checkout. It is used to discard changes in the working directory by replacing them with the last committed version. On the other hand, git reset is more commonly used for moving the branch pointer and can be more powerful, potentially discarding commits. git checkout is a safer option for simply undoing changes in the working directory.
In complex projects, maintaining a clean history can involve the use of git rebase -i, which stands for interactive ________.
- iteration
- interface
- indexing
- rebase
The correct option is (d) rebase. The command git rebase -i allows for interactive rebasing, providing a powerful interface to modify commit history. This is particularly useful for rearranging, editing, or combining commits to maintain a cleaner project history.
How does Git handle code reviews differently from traditional version control systems?
- Integrated code review tools
- Manual code reviews through email
- No support for code reviews
- Automatic code reviews during commit
Git integrates code review tools directly into the workflow. This allows for seamless collaboration, with developers able to comment on specific lines of code, suggest changes, and ensure code quality before merging.
In the context of Git, what does the term 'merge conflict' specifically refer to?
- Combining changes from multiple branches that do not conflict
- An error that occurs when attempting to merge unrelated branches
- A situation where Git cannot automatically reconcile differences between branches
- Merging branches with a linear commit history
In the context of Git, the term 'merge conflict' specifically refers to a situation where Git cannot automatically reconcile differences between branches. This occurs when changes in one branch conflict with changes in another, and Git needs manual intervention to resolve the conflicting edits. It is essential to understand how to navigate and resolve merge conflicts to maintain a clean and consistent version history in collaborative development environments. The other options describe scenarios that do not precisely define a merge conflict in Git.
A developer accidentally committed a file that should not be tracked by Git. What command should they use to rectify this before pushing?
- git reset HEAD
- git rm --cached
- git checkout -- filename
- git revert
The correct option is c. git checkout -- filename. This command discards changes in the working directory and unstages the file, effectively "uncommitting" it. git reset HEAD and git rm --cached are used for different purposes. git reset HEAD unstages changes, and git rm --cached unstages the file but also stages the removal. git revert is used to create a new commit that undoes a previous commit.
In what scenario might you use a git filter-branch?
- Restructuring the commit history
- Updating remote branches
- Resolving merge conflicts
- Renaming a local branch
The git filter-branch command is used to rewrite, restructure, or filter the commit history. It can be useful when you need to make substantial changes to the history, such as removing sensitive information or restructuring the commit tree.