Git Questions
Warm up for Git questions with most asked questions and answers for junior, mid, and senior roles.
How is git merge different from git rebase?
Show AnswerHide Answer
Git merge: moves changes from a branch to another and creates a merge commit. History is preserved.
Git rebase: moves changes from a branch to another but alters the history by moving the origin branch's starting point. It does not create a merge commit.
What consists of a commit object?
Show AnswerHide Answer
The commit object contains the directory tree object hash, parent commit hash, author, committer, date and message.
Can you tell something about git reflog?
Show AnswerHide Answer
Git reflog is a command that shows a more detailed history of a branch.
What do you understand about the Staging area in Git?
Show AnswerHide Answer
The staging area is a temporary area where Git stores changes that have not yet been committed. When you commit, Git moves the changes from the staging area to the commit history.
What is Git Bisect and how do you use it?
Show AnswerHide Answer
Git bisect is a tool that allows you to find the commit that introduced a bug in your code.
Difference between git fetch and git pull.
Show AnswerHide Answer
The git fetch command downloads commits, files from a remote repository into your local repo.
The git pull fetches and merges any commits from the remote branch
What is the functionality of git ls-tree?
Show AnswerHide Answer
The git ls-tree command is used to list the contents of a tree object.
What is the difference between git revert and git reset?
Show AnswerHide Answer
The git revert command is a forward-moving undo operation that offers a safe method of undoing changes. Instead of deleting or orphaning commits in the commit history, a revert will create a new commit that inverses the changes specified.
The git reset command is used when we want to move the repository back to a previous commit , discarding any changes made after that commit.
What is SubGit and why is it used?
Show AnswerHide Answer
SubGit is a Git submodule. It is a way to add a repository as a submodule to another repository.