{"id":589,"date":"2026-05-23T06:28:33","date_gmt":"2026-05-23T06:28:33","guid":{"rendered":"https:\/\/logicnextgen.com\/tutorials\/?page_id=589"},"modified":"2026-05-23T14:35:32","modified_gmt":"2026-05-23T14:35:32","slug":"git-interview-questions-answers","status":"publish","type":"page","link":"https:\/\/logicnextgen.com\/tutorials\/git-interview-questions-answers\/","title":{"rendered":"Git Interview Questions &amp; Answers"},"content":{"rendered":"\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-1 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>1. What is Git?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Git is a distributed version control system used to track changes in source code during software development.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-2\" style=\"color:#ff8d00\"><strong>2. What is GitHub?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">GitHub is a cloud-based platform used to host Git repositories and collaborate on projects.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-3\" style=\"color:#ff8d00\"><strong>3. What is the difference between Git and GitHub?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Git<\/strong><\/td><td><strong>GitHub<\/strong><\/td><\/tr><tr><td>Version control tool<\/td><td>Hosting platform<\/td><\/tr><tr><td>Works locally<\/td><td>Works online<\/td><\/tr><tr><td>Tracks code changes<\/td><td>Enables collaboration<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-4\" style=\"color:#ff8d00\"><strong>4. What is a repository in Git?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A repository is a storage location that contains project files and version history.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-5\" style=\"color:#ff8d00\"><strong>5. What is a local repository and remote repository?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Local Repository<\/strong><\/td><td><strong>Remote Repository<\/strong><\/td><\/tr><tr><td>Stored on local machine<\/td><td>Stored on server\/GitHub<\/td><\/tr><tr><td>Used for local work<\/td><td>Used for team collaboration<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-6\" style=\"color:#ff8d00\"><strong>6. What is a commit in Git?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A commit is a snapshot of changes saved to the repository.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git commit -m \"Added login feature\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-7\" style=\"color:#ff8d00\"><strong>7. What is the difference between <\/strong><strong>git pull<\/strong><strong> and <\/strong><strong>git fetch<\/strong><strong>?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>git pull<\/strong><\/td><td><strong>git fetch<\/strong><\/td><\/tr><tr><td>Fetches and merges changes<\/td><td>Only downloads changes<\/td><\/tr><tr><td>Updates local branch automatically<\/td><td>Does not merge automatically<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-8\" style=\"color:#ff8d00\"><strong>8. What is the difference between <\/strong><strong>git merge<\/strong><strong> and <\/strong><strong>git rebase<\/strong><strong>?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>git merge<\/strong><\/td><td><strong>git rebase<\/strong><\/td><\/tr><tr><td>Combines branches with merge commit<\/td><td>Rewrites commit history<\/td><\/tr><tr><td>Preserves history<\/td><td>Creates cleaner history<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-9\" style=\"color:#ff8d00\"><strong>9. What is branching in Git?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Branching allows developers to work on features independently without affecting the main code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-10\" style=\"color:#ff8d00\"><strong>10. What is a merge conflict?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A merge conflict occurs when Git cannot automatically merge changes from different branches.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-11\" style=\"color:#ff8d00\"><strong>11. How do you resolve merge conflicts in Git?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open conflicted files<\/li>\n\n\n\n<li>Edit and resolve conflicts<\/li>\n\n\n\n<li>Save files<\/li>\n\n\n\n<li>Run :  git add &amp; git commit<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-12\" style=\"color:#ff8d00\"><strong>12. What is Git staging area?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The staging area is an intermediate area where changes are prepared before committing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-13\" style=\"color:#ff8d00\"><strong>13. What is the use of <\/strong><strong>git add<\/strong><strong> command?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It adds changes to the staging area.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git add file.txt<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-14\" style=\"color:#ff8d00\"><strong>14. What is the use of <\/strong><strong>git commit<\/strong><strong> command?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It saves staged changes into the repository history.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-15\" style=\"color:#ff8d00\"><strong>15. What is the use of <\/strong><strong>git push<\/strong><strong> command?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It uploads local commits to the remote repository.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git push origin main<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-16\" style=\"color:#ff8d00\"><strong>16. What is the use of <\/strong><strong>git clone<\/strong><strong> command?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It copies an existing remote repository to the local machine.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone &lt;repository-url><\/code><\/pre>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-17 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>17. What is the use of <\/strong><strong>git status<\/strong><strong> command?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It shows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Modified files<\/li>\n\n\n\n<li>Staged files<\/li>\n\n\n\n<li>Untracked files<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-18\" style=\"color:#ff8d00\"><strong>18. How do you create a branch in Git?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">git branch feature<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-19\" style=\"color:#ff8d00\"><strong>18. How do you delete a branch in Git?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">git branch -d feature<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-20\" style=\"color:#ff8d00\"><strong>19. What is a pull request in GitHub?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A pull request is a request to merge code changes into another branch<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-21\" style=\"color:#ff8d00\"><strong>20. What are the advantages of Git?<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Fast performance<\/li>\n\n\n\n<li>Distributed system<\/li>\n\n\n\n<li>Easy branching<\/li>\n\n\n\n<li>Strong version tracking<\/li>\n\n\n\n<li>Collaboration support<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. What is Git? Git is a distributed version control system used to track changes in source code during software development. 2. What is GitHub? GitHub is a cloud-based platform used to host Git repositories and collaborate on projects. 3. What is the difference between Git and GitHub? Git GitHub Version control tool Hosting platform &#8230; <a title=\"Git Interview Questions &amp; Answers\" class=\"read-more\" href=\"https:\/\/logicnextgen.com\/tutorials\/git-interview-questions-answers\/\" aria-label=\"Read more about Git Interview Questions &amp; Answers\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-589","page","type-page","status-publish"],"_links":{"self":[{"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/pages\/589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/comments?post=589"}],"version-history":[{"count":6,"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/pages\/589\/revisions"}],"predecessor-version":[{"id":644,"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/pages\/589\/revisions\/644"}],"wp:attachment":[{"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/media?parent=589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}