What is the effect of git reset --hard HEAD^?
- Moves HEAD to the previous commit
- Discards changes in the working directory
- Unstages changes from the index
- Creates a new branch
The command git reset --hard HEAD^ resets the current branch to the previous commit, discarding all changes in the working directory and staging area. It's a forceful reset, so use it with caution as it cannot be undone.
Which Git command is used to view changes made by each commit?
- git log
- git show
- git diff
- git status
The git log command is used to view the commit history of a repository. It displays information about each commit, including the commit message, author, date, and a unique identifier. This helps in understanding the changes made in each commit in chronological order.
In Git, git _______ shows the status of changes as untracked, modified, or staged.
- log
- status
- diff
- branch
The git status command provides information about the current state of the working directory, indicating which files are untracked, modified, or staged for the next commit.
What advanced Git techniques can be used to manage database schema versions efficiently?
- Using Git submodules
- Employing Git hooks
- Leveraging Git LFS
- Implementing database migrations
Database schema versions can be efficiently managed using techniques like database migrations, where changes to the schema are version-controlled and applied systematically. Git hooks and Git LFS are useful for other purposes, but they may not directly address schema versioning concerns.
A project requires frequent updates to large media files. What strategy should be adopted in Git to manage these files efficiently without affecting the repository's performance?
- Git LFS (Large File Storage)
- Git submodules
- Git merge strategies
- Git revert
To efficiently manage large media files without affecting the repository's performance, the project should adopt the Git LFS (Large File Storage) strategy, specifically designed for handling such files in Git.
The git stash ________ command allows you to view all the stashed changes in the repository.
- Apply
- Drop
- List
- Pop
The correct option is c. List. The git stash list command displays a list of all stashed changes in the repository, showing their stash IDs and descriptions. It helps you identify and manage stashed changes.
How can you view the configuration settings of a Git repository?
- git config
- git info
- git settings
- git show
To view the configuration settings of a Git repository, you can use the git config command. This command shows both repository-specific and global configuration settings.
When collaborating on a project, you typically push your changes to the _______ branch of the remote repository.
- master
- main
- origin
- remote
By convention, when collaborating, changes are pushed to the master branch. However, note that some projects may use main as the default branch.
If you have committed the wrong files to Git, what command can you use to undo this last commit?
- git reset --soft HEAD^
- git revert HEAD
- git reset --hard HEAD^
- git reset HEAD^
The correct option, git reset --hard HEAD^, is also used in this scenario to completely undo the last commit along with the changes. It discards the commit and resets the branch pointer. Other options are for different use cases: preserving changes, creating a new commit to undo changes, and unstaging changes.
A development team is experiencing slow performance when working with a Git repository containing large binary files. What Git feature should they consider implementing?
- Git LFS (Large File Storage)
- Shallow clones
- Git submodules
- Git Hooks
The team should consider implementing Git LFS (Large File Storage) to efficiently handle large binary files. Git LFS is designed for versioning large files, preventing performance issues.