Sign-In
Register
Please choose an option to Register
Register as Freelancer
Register as Client
Close
Bellgigs
Bridging Skills and Opportunities
Sign-In
Register
☰
Back To Interview Q & A
Back To Interview Q & A
Home
About Us
Apply for Jobs
Build Resume
Interview Questions & Answers
Contact Us
Help
Suggested Certification for Git
GitLab Certified Git Associate
Recommended Book 1 for Git
★★★★☆
Check Amazon for current price
View Deal
On Amazon
Recommended Book 2 for Git
★★★★☆
Check Amazon for current price
View Deal
On Amazon
Recommended Book 3 for Git
★★★★☆
Check Amazon for current price
View Deal
On Amazon
Recommended Book 4 for Git
★★★★☆
Check Amazon for current price
View Deal
On Amazon
Recommended Book 5 for Git
★★★★☆
Check Amazon for current price
View Deal
On Amazon
Note:
*Check out these useful books! As an Amazon Associate I earn from qualifying purchases.
Interview Questions and Answers
1. What is the purpose of `git cherry-pick`?
`git cherry-pick` allows you to apply a specific commit from one branch to another branch.
2. How can you view the commit history in Git?
You can view the commit history using `git log`. Use options like `git log --oneline` for a condensed view, `git log --graph` for a graphical view, and `git log --author=
` to filter by author.
3. How do you configure Git?
Git is configured using `git config`. You can set global configuration options with `git config --global
` and repository-specific options with `git config
`.
4. What are Git hooks and how are they used?
Git hooks are scripts that run automatically before or after certain Git events, such as commit, push, and receive. They can be used to enforce coding standards, run tests, or perform other automated tasks.
5. How do you delete a branch in Git?
To delete a local branch, use `git branch -d
` (only if the branch is fully merged) or `git branch -D
` (to force deletion, even if not merged). To delete a remote branch, use `git push origin --delete
`.
6. What is a `.gitignore` file and how is it used?
A `.gitignore` file specifies intentionally untracked files that Git should ignore. This is useful for excluding build artifacts, temporary files, or sensitive information from being committed.
7. How do you contribute to an open-source project using Git?
Typically, you fork the repository, clone your fork, create a branch for your changes, commit your changes, push your branch to your fork, and then create a pull request to the original repository.
8. What is the difference between `git rebase` and `git merge`?
`git merge` creates a merge commit to integrate changes. `git rebase` rewrites the commit history by moving your branch onto another branch, creating a cleaner, linear history. Rebase can be more complex and risky if not used carefully.
9. How do you resolve common Git errors like "detached HEAD"?
A detached HEAD state occurs when youre not on a branch. To fix it, create a new branch from the commit youre on (`git checkout -b
`) or checkout an existing branch (`git checkout
`).
10. How do you merge branches in Git?
To merge a branch into your current branch, use the command `git merge
`. This will combine the changes from the specified branch into your current branch.
11. What is a merge conflict and how do you resolve it?
A merge conflict occurs when Git cannot automatically merge changes from two different branches. You need to manually edit the conflicting files to resolve the conflict, then stage and commit the changes.
12. What is the purpose of `git stash`?
`git stash` allows you to save uncommitted changes temporarily, cleaning up your working directory. You can then restore these changes later using `git stash pop` or `git stash apply`.
13. How do you undo a commit in Git?
There are several ways to undo a commit. `git revert
` creates a new commit that undoes the changes from the specified commit. `git reset --hard
` moves the branch pointer back to the specified commit, discarding all subsequent commits (use with caution!).
14. What is the difference between `git reset --soft`, `git reset --mixed`, and `git reset --hard`?
`git reset --soft` moves the branch pointer but keeps the changes staged. `git reset --mixed` (the default) moves the branch pointer and unstages the changes. `git reset --hard` moves the branch pointer and discards the changes.
15. How do you rename a local branch in Git?
To rename a local branch, use the command `git branch -m
`.
16. What is Git and why is it used?
Git is a distributed version control system that tracks changes to files over time. Its used for collaboration, managing code versions, and reverting to previous states.
17. What are the basic Git commands?
Basic Git commands include `git init` (initialize a repository), `git clone` (copy a repository), `git add` (stage changes), `git commit` (record changes), `git push` (upload changes), `git pull` (download changes), and `git status` (check repository status).
18. What is the difference between `git fetch` and `git pull`?
`git fetch` downloads objects and refs from another repository but doesnt integrate them into your working copy. `git pull` downloads objects and refs AND integrates them into your working copy, essentially doing a `git fetch` followed by a `git merge`.
19. What is a Git branch and why is it important?
A Git branch is a pointer to a snapshot of your changes. It allows you to work on new features or bug fixes in isolation without affecting the main codebase, making collaboration and parallel development easier.
20. How do you create a new branch in Git?
You can create a new branch using the command `git branch
`. To switch to the newly created branch, use `git checkout
` or `git checkout -b
` to create and switch in one command.