{"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-122fbbf608c875f739465cfc8081f92c 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-fb2b83bbd28905db68796a83113eab52\" 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-08149d9d4989ed727ba982067d1b092d\" 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-533da147c89b1ba6a0a6858c28279317\" 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-010db9db34f4acd3891ff394ba972b6a\" 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-2c37964ae43e13e74d50668da2b6ac17\" 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-1e355c97a786a8622b4728e7305b547c\" 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-f154526fc2bca045b9b4f62c6cad208e\" 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-2892a1e1b1effee0aa6b0da5770ec379\" 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-7c923b5f5a6f2f6b2a0abda4f54bdb13\" 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-0415a0fa7834da16cb94fbaa0561b29f\" 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-d1fccee3bb3c32b3b0bb5f9e41401f0f\" 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-1d48066e559b99de03675c5d3e0a5983\" 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-392fa25c29a8b3c32dde32f8ec4c3896\" 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-1d3ee214218a081574d824f5c5e6ec80\" 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-f772523fe3e700f2f1bfbdc275c7be57\" 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-24170c71f586799b2bd6d5d9dc08bd8e 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-720e1505015c1a35dece61c2d597fa59\" 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-334910831cc459fd43560ac65201b268\" 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-a4561bc37d06ab2b4695fc58c2ff1bc3\" 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-c16d79180b1c133842a9d7c15e844780\" 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}]}}