Git Questions

Warm up for Git questions with most asked questions and answers for junior, mid, and senior roles.

Mid

Name a few Git commands with their function.

Show Answer

The following are the most common Git commands:

  • git add - adds files to the staging area
  • git commit - commits the current changes
  • git push - pushes the current branch to a remote repository
  • git pull - pulls changes from a remote repository
  • git status - shows the status of the current repository
  • git log - shows the history of the current repository
Mid

What does git pull origin master do?

Show 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.

Mid

What does the git push command do?

Show Answer

The "git push" command is used to push changes to a remote repository. It pushes the current branch to a remote repository.

Mid

What does git clone do?

Show Answer

The git clone command is used to clone a repository from a remote repository.

Mid

What is Git stash?

Show 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.

Mid

What is the functionality of git clean command?

Show Answer

The git clean command is used to remove untracked files from the working directory.

Mid

What is the difference between fork, branch, and clone?

Show 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.

Mid

What is git stash drop?

Show Answer

Git stash drop is a command that removes a stash from the stash list.

Mid

What is “git cherry-pick”?

Show Answer

Git cherry-pick is a command that allows you to cherry-pick a commit to a branch.

Mid

What are the advantages of using Git?

Show Answer

Some of the advantages of Git are:

  • Speed
  • Simplicity
  • Fully Distributed
  • Excellent support for parallel development, support for hundreds of parallel branches.
  • Integrity
Mid

What language is used in Git?

Show 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.

Mid

What is the correct syntax to add a message to a commit?

Show Answer

The correct syntax is:

git commit -m “message”
Mid

What does git status command do?

Show Answer

Git status command is used to show the status of the current repository.

Mid

What is the HEAD term in Git?

Show Answer

The HEAD in Git is the pointer to the current branch reference.

Mid

What does git diff command do?

Show Answer

Git diff command is used to show the difference between two commits.