Git Questions
Warm up for Git questions with most asked questions and answers for junior, mid, and senior roles.
Name a few Git commands with their function.
Show AnswerHide Answer
The following are the most common Git commands:
git add
- adds files to the staging areagit commit
- commits the current changesgit push
- pushes the current branch to a remote repositorygit pull
- pulls changes from a remote repositorygit status
- shows the status of the current repositorygit log
- shows the history of the current repository
What does git pull origin master do?
Show AnswerHide Answer
"git pull origin master" is used to pull changes from a remote repository. It pulls the latest changes from the master branch of the remote repository and merges them into the current branch.
What does the git push command do?
Show AnswerHide Answer
The "git push" command is used to push changes to a remote repository. It pushes the current branch to a remote repository.
What does git clone do?
Show AnswerHide Answer
The git clone command is used to clone a repository from a remote repository.
What is Git stash?
Show AnswerHide Answer
Git stash is a way to store and restore changes to a file or a set of files. It is used to store changes that have not yet been committed.
What is the functionality of git clean command?
Show AnswerHide Answer
The git clean command is used to remove untracked files from the working directory.
What is the difference between fork, branch, and clone?
Show AnswerHide Answer
Fork is a way to create a copy of an existing repository. It is used to create a copy of an existing repository.
Branch is a way to create a new branch in an existing repository. It is used to create a new branch in an existing repository.
Clone is a way to clone a repository from a remote repository. It is used to clone a repository from a remote repository.
What is git stash drop?
Show AnswerHide Answer
Git stash drop is a command that removes a stash from the stash list.
What is “git cherry-pick”?
Show AnswerHide Answer
Git cherry-pick is a command that allows you to cherry-pick a commit to a branch.
What are the advantages of using Git?
Show AnswerHide Answer
Some of the advantages of Git are:
- Speed
- Simplicity
- Fully Distributed
- Excellent support for parallel development, support for hundreds of parallel branches.
- Integrity
What language is used in Git?
Show AnswerHide Answer
The Git language is written in C. The C language makes this possible by reducing the overhead of runtimes associated with high-level languages and helping git to perform better.
What is the correct syntax to add a message to a commit?
Show AnswerHide Answer
The correct syntax is:
git commit -m “message”
What does git status command do?
Show AnswerHide Answer
Git status command is used to show the status of the current repository.
What is the HEAD term in Git?
Show AnswerHide Answer
The HEAD in Git is the pointer to the current branch reference.
What does git diff command do?
Show AnswerHide Answer
Git diff command is used to show the difference between two commits.