GIT Interview Questions and Answers
Freshers / Beginner level questions & answers
Ques 1. What is Git?
Git is a distributed version control system that helps track changes in source code during software development.
Ques 2. Explain the difference between Git and GitHub.
Git is a version control system, while GitHub is a web-based platform for hosting and collaborating on Git repositories.
Ques 3. What is a commit in Git?
A commit is a snapshot of changes made to a Git repository. It creates a new revision in the version history.
Ques 4. What is a Git repository?
A Git repository is a storage location where a project's files and their revision history are stored.
Ques 5. Explain the purpose of 'git pull' command.
'git pull' is used to fetch and merge changes from a remote repository to the current branch.
Ques 6. What is the purpose of the '.gitignore' file?
The '.gitignore' file specifies files and directories that should be ignored by Git, preventing them from being tracked in the repository.
Ques 7. Explain the concept of Git branching.
Git branching allows developers to create independent lines of development, enabling them to work on features or bug fixes without affecting the main codebase until ready.
Ques 8. What is a Git stash, and how is it used?
A Git stash is a way to temporarily save changes that are not ready to be committed. It allows you to switch branches without committing or discarding changes.
Ques 9. How do you rename a Git branch?
You can use the 'git branch -m' command followed by the new branch name to rename a Git branch.
Ques 10. How can you view the commit history in Git?
You can use 'git log' to view the commit history, displaying information such as commit messages, authors, and timestamps.
Ques 11. Explain the purpose of the 'git clone' command.
'git clone' is used to create a copy of a remote repository on your local machine.
Ques 12. How do you amend the last Git commit message?
You can use 'git commit --amend' followed by the new commit message to amend the last commit.
Ques 13. How do you create a tag in Git?
You can use 'git tag' followed by the tag name to create a tag at the current commit.
Ques 14. Explain the purpose of the 'git log' command with the '--oneline' option.
'git log --oneline' provides a compact view of commit history, displaying each commit as a single line with a shortened commit hash and commit message.
Most helpful rated by users: