Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
Basic Questions
What is Git?
Answer : Git is a distributed version control system that enables several individuals to collaborate on a project at once without erasing each other’s edits. It makes working together more effectively, monitoring changes, and going back to earlier phases easier.
Explain the difference between git pull
and git fetch
.
Answer : git fetch downloads, without merging, the most recent changes from the remote repository into your local repository. Git pull completes the fetching and merging processes in one go.
What is a commit in Git?
Answer : a commit is a snapshot of the repository’s modifications. In addition to the author, timestamp, and commit message, each commit has a unique ID.
Intermediate Questions
How do you create a new branch in Git?
Answer : You can use git branch branch_name to establish a new branch and git checkout branch_name to switch to it, or you can do both at once with git checkout -b branch_name.
Explain the concept of “staging” in Git
Answer : The practice of adding changes to Git’s staging area, or index, is known as staging. You can make modifications in the staging area before committing them. Git add may be used to add files to the staging area.
What is a merge conflict and how do you resolve it?
Answer : When two branches contain changes in the same section of a file and Git is unable to automatically combine them, a merge conflict arises. You must manually edit the files that are at odds with one another, eliminate conflict markers, and then commit the fixed modifications in order to fix the issue.
Advanced Questions
Explain the difference between git rebase
and git merge
Answer : In contrast to git rebase, which moves or merges a series of commits into a single base commit, git merge creates a new merging commit that incorporates modifications from several branches. While merging maintains the branch history, rebasing produces a linear history.
What is the purpose of git stash
?
Answer : To work on something else and come back to the changes later, use git stash to temporarily store changes in the working directory that are not ready to be committed. Git stash apply and Git stash pop can be used to apply stored changes.
How do you undo the last commit?
Answer : The last commit can be undone by creating a new commit using the command git reverse HEAD. As an alternative, you may use git reset –hard HEAD~1 to remove all changes or git reset –soft HEAD~1 to relocate the HEAD pointer to the prior commit while maintaining modifications in the working directory.
What is a Git hook and what are its uses?
Answer : scripts known as “git hooks” are run automatically either before or after particular actions, such pushing or committing. They may be used for many different things, such as executing tests, interacting with other tools, and enforcing code standards.
Thanks for sharing it helps me a lot.
Very helpful blog… This blog is helpful for new users of GitHub .. we should learn from this blog, how to use Github.