To save changes in a new stash, you would use git stash ______.
- save
- create
- push
- store
The command to stash changes is git stash save, which saves the changes in the stash without committing them to the repository. This is useful when you need to switch to a different branch or address an urgent issue.
A developer discovers that confidential files were accidentally committed to a public Git repository. What steps should be taken to resolve this?
- Identify and note down the commit hash. Use git reset or git revert to undo the commit.
- Use git rm to remove the files from the repository, commit the changes, and push.
- Create a new branch, cherry-pick the desired commits without the confidential files, and push.
- Use git filter-branch to remove the files from the entire history and force push the updated repository.
Option 2 involves removing the confidential files and making a clean commit, ensuring that sensitive information is not exposed. Other options may have drawbacks or potential risks, such as force-pushing to a shared repository.
What is a Git Hook primarily used for?
- Executing custom scripts
- Managing branches
- Resolving merge conflicts
- Creating repositories
Git hooks are scripts that run automatically before or after specific Git events. They are primarily used for executing custom scripts, such as enforcing coding standards or triggering automated tests.
How do branching strategies in Git influence project management in large enterprises?
- Facilitate Parallel Development
- Slow Down the Development Process
- Minimize Collaboration
- Increase Code Conflicts
Git branching strategies enable parallel development, allowing teams to work on features independently. This enhances collaboration and accelerates project delivery by avoiding conflicts during simultaneous development.
What Git feature is particularly useful for managing different releases in open source projects?
- Git Branching
- Git Forking
- Git Merging
- Git Cloning
Git branching is particularly useful for managing different releases in open source projects. Each branch can represent a different version or release, allowing for parallel development and easy maintenance of multiple code bases.
The git _______ command is used to change a commit message that hasn't been pushed yet.
- commit --amend
- commit --modify
- commit --edit
- commit --change
The correct option is commit --amend. This command allows you to modify the last commit's message. It's useful when you need to make small changes or corrections to the commit message before pushing it to the remote repository.
When setting up a new remote repository, the command git remote add origin _______ is used.
- https://github.com/user/repo.git
- origin
- master
- git remote
The correct option is a. https://github.com/user/repo.git. This option represents the URL of the remote repository, and 'origin' is a common name given to the remote. While 'origin' is used in the command, it is not a placeholder for the repository URL. It's important to correctly specify the remote repository's URL when adding a remote to your local repository to establish a connection for pushing and pulling changes.
What is a common use of git stash in Git?
- Discarding changes
- Storing changes temporarily
- Applying changes to the remote repository
- Deleting the entire repository
Git stash is commonly used to temporarily store changes that are not ready to be committed. This is useful when you need to switch to a different branch or address an urgent issue, allowing you to save your work without committing it.
To see a graphical representation of the commit history, you can use git log --_______.
- graph
- oneline
- pretty
- graphoneline
The correct option is git log --graph. This option provides a graphical representation of the commit history, showing branches and merges.
What is the impact of having a large number of branches in a Git repository on its performance?
- A large number of branches has no impact on Git repository performance.
- More branches lead to faster Git operations due to parallel processing.
- Having many branches can slow down Git operations like cloning and fetching.
- Git performance is not affected by the number of branches in a repository.
Having a large number of branches in a Git repository can negatively impact performance, especially during operations like cloning and fetching. Each branch adds overhead, and repositories with excessive branches may experience slower operations.