Debug School

Akanksha
Akanksha

Posted on

Top 30 gitHub Interview Questions with Answers

1. What is Git?

A. A distributed version control system
B. A code collaboration platform
C. A text editor
D. A programming language
Answer: A

2. Which command is used to initialize a Git repository?

A. git init
B. git start
C. git create
D. git begin
Answer: A

3. What is the primary purpose of Git?

A. Managing project issues
B. Collaborative coding
C. Version control
D. Server hosting
Answer: C

4. What is the purpose of a Git commit?

A. To push code to a remote repository
B. To record a snapshot of the project's changes
C. To merge two branches
D. To create a new branch
Answer: B

5. Which Git command is used to stage changes for commit?

A. git stage
B. git commit
C. git add
D. git push
Answer: C

6. What does a Git branch represent?

A. A new project
B. A different repository
C. A line of development
D. A specific issue
Answer: C

7. How do you create a new branch in Git?

A. git branch new-branch
B. git create-branch new-branch
C. git new-branch
D. git checkout -b new-branch
Answer: D

8. What is a Git merge?

A. Combining changes from one branch to another
B. Creating a new repository
C. Cloning a repository
D. Reverting to a previous commit
Answer: A

9. How do you resolve a Git merge conflict?

A. Delete the conflicting branch
B. Revert to a previous commit
C. Manually edit the conflicting files
D. Git resolves it automatically
Answer: C

10. What is a Git remote?

A. A remote control for your computer
B. A remote server where your Git repository is hosted
C. A remote branch
D. A remote user's code
Answer: B

11. What is a Git pull request?

A. A request to fetch the latest code
B. A request for code review and merging changes into a branch
C. A request to delete a branch
D. A request to rename a branch
Answer: B

12. What is a Git fork?

A. A copy of a Git repository under your GitHub account
B. A branch with minimal code changes
C. A way to create a local repository
D. A type of code review
Answer: A

13. How do you update your local repository with changes from the remote repository?

A. git clone
B. git pull
C. git push
D. git fetch
Answer: B

14. What is a Git stash?

A. A secret repository
B. A way to save changes without committing them
C. A separate branch
D. A remote repository
Answer: B

15. What is the purpose of the .gitignore file in Git?

A. To specify files and directories to be ignored in version control
B. To list all the files to be committed
C. To track changes in binary files
D. To define branch names
Answer: A

16. What is a Git tag?

A. A branch name
B. A marker for a specific commit
C. A remote repository
D. A type of Git submodule
Answer: B

17. What is a GitHub Gist?

A. A type of issue on GitHub
B. A repository with a large number of stars
C. A way to share code snippets
D. A forked repository
Answer: C

18. What is a GitHub repository wiki?

A. A documentation section for a repository
B. A chat room for repository collaborators
C. A place to store secret project information
D. A graphical representation of code
Answer: A

19. How do you create a new branch and switch to it in Git?

A. git branch new-branch
B. git checkout -b new-branch
C. git create-branch new-branch
D. git switch new-branch
Answer: B

20. What is a Git rebase?

A. A type of merge conflict
B. A way to rewrite the commit history
C. A command to delete branches
D. A command to fetch remote changes
Answer: B

21. What is a Git submodule?

A. A small Git repository within a Git repository
B. A branch with minimal code changes
C. A remote Git repository
D. A way to rename a Git repository
Answer: A

22. What is the purpose of the git log command?

A. To list all files in a repository
B. To view the commit history of a Git repository
C. To commit changes to a remote repository
D. To merge branches
Answer: B

23. What is a Git hook?

A. A way to catch errors in code
B. A tool for code reviews
C. A script that runs at certain Git events
D. A type of branch
Answer: C

24. How do you delete a remote branch in Git?

A. git branch -d branch-name
B. git remove branch-name
C. git push origin --delete branch-name
D. git delete-branch branch-name
Answer: C

25. What is a Git cherry-pick?

A. A type of fruit
B. A way to pick commits from one branch and apply them to another
C. A method to create new branches
D. A tool for code review
Answer: B

26. What is the purpose of the git bisect command?

A. To split a Git repository into multiple repositories
B. To perform binary search to find the commit that introduced a bug
C. To merge branches
D. To revert changes in a branch
Answer: B

27. What is a Git rebase interactive?

A. A method to interact with Git support
B. A way to make code changes without interaction
C. A chat room for Git users
D. A method for rewriting commit history interactively
Answer: D

28. What is a Git tag?

A. A version of Git software
B. A way to mark a specific commit
C. A comment on a Git commit
D. A branch name
Answer: B

29. How do you undo the last Git commit without losing the changes?

A. git reset --soft HEAD^
B. git undo
C. git rollback
D. git remove
Answer: A

30. What is the purpose of the .gitattributes file in Git?

A. To specify a project's address
B. To store credentials
C. To configure file-specific settings
D. To define branch names
Answer: C

31. How do you create a pull request in GitHub?

A. Using the git request command
B. Via the GitHub website
C. By sending an email
D. By creating a new branch
Answer: B

32. What is a GitHub issue?

A. A problem with GitHub itself
B. A discussion thread for a repository
C. A code review request
D. A pull request
Answer: B

33. What is a GitHub repository template?

A. A template for code reviews
B. A template for code documentation
C. A template for creating new repositories with predefined files and settings
D. A template for licensing code
Answer: C

Top comments (0)