{"id":366,"date":"2026-10-13T22:31:18","date_gmt":"2026-10-13T22:31:18","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2014\/08\/18\/interview-questions-on-git-github-and-gitlab\/"},"modified":"2026-10-13T22:31:18","modified_gmt":"2026-10-13T22:31:18","slug":"interview-questions-on-git-github-and-gitlab","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/interview-questions-on-git-github-and-gitlab\/","title":{"rendered":"Git, GitHub, and GitLab Interview Questions: Practical Answers and Command Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This guide turns a long list of interview prompts into practical answers for engineers preparing for DevOps, platform, and software delivery roles. You will review core Git concepts, command-level examples, and where Git, GitHub, and GitLab fit in day-to-day team workflows.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Originally published on 2014-08-18; fully revised and updated.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Original post: <a href=\"https:\/\/www.devopsschool.com\/blog\/interview-questions-on-git-github-and-gitlab\/\">Git Interview Questions and Answer Part \u2013 6<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2014\/08\/interview-questions-on-git-.png\" alt=\"Interview questions on Git GitHub and GitLab\" width=\"600\" height=\"400\" \/><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What interviewers usually test<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Most Git interview rounds check whether you can explain concepts <em>and<\/em> apply them with commands. Expect a mix of fundamentals, branch strategy, collaboration flow, and incident recovery.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Core concepts: repository, commit, staging area, HEAD, branch, merge, rebase<\/li><li>Daily command fluency: status, diff, add, commit, log, pull, push<\/li><li>Collaboration: pull\/merge requests, conflict resolution, branch cleanup<\/li><li>Platform awareness: GitHub vs GitLab and CI\/CD integration<\/li><li>Troubleshooting: auth failures, diverged branches, bad commits<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Core Git interview questions and concise answers<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>What is Git?<\/strong> Git is a distributed version control system that tracks file changes and enables collaborative development.<\/li><li><strong>What is a repository?<\/strong> A repository (repo) stores project files plus history (commits, branches, tags).<\/li><li><strong>What is the staging area (index)?<\/strong> It is an intermediate area where you select exactly what goes into the next commit.<\/li><li><strong>What does <code>git commit -m<\/code> do?<\/strong> It records staged changes and attaches the provided commit message.<\/li><li><strong>What does <code>git push<\/code> do?<\/strong> It sends local commits to a remote repository reference (for example, <code>origin\/main<\/code>).<\/li><li><strong>What is <code>git clone<\/code> used for?<\/strong> It copies an existing remote repository locally, including history and refs.<\/li><li><strong>What is the difference between <code>git remote<\/code> and <code>git clone<\/code>?<\/strong> <code>git clone<\/code> creates a local copy; <code>git remote<\/code> manages remote names and URLs in an existing local repo.<\/li><li><strong>What is HEAD?<\/strong> HEAD is a reference to your current checked-out commit (typically the tip of the active branch).<\/li><li><strong>What is a bare repository?<\/strong> A repository without a working tree, commonly used as a central\/shared remote.<\/li><li><strong>What is <code>git stash<\/code>?<\/strong> It temporarily shelves uncommitted changes so you can switch context safely.<\/li><li><strong>What does <code>git stash drop<\/code> do?<\/strong> It removes a stored stash entry after you no longer need it.<\/li><li><strong>What does a commit object contain?<\/strong> A snapshot reference (tree), parent commit reference(s), author\/committer metadata, timestamps, and message.<\/li><li><strong>What language is Git written in?<\/strong> Git core is primarily written in C, with supporting tooling historically including shell and Perl scripts.<\/li><li><strong>How is Git different from SVN?<\/strong> Git is distributed and local-first; SVN is centralized with a single canonical repository workflow.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Essential commands you should be able to explain<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Interviewers often ask you to narrate what each command does and when you would choose it.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php language-bash\"><span class=\"hljs-comment\"># Initialize or copy a repository<\/span>\ngit init\ngit <span class=\"hljs-keyword\">clone<\/span> https:<span class=\"hljs-comment\">\/\/example.com\/team\/app.git<\/span>\n\n<span class=\"hljs-comment\"># Inspect local state<\/span>\ngit status\ngit diff\ngit log --oneline --graph --decorate -n <span class=\"hljs-number\">10<\/span>\n\n<span class=\"hljs-comment\"># Stage and commit<\/span>\ngit add .\ngit commit -m <span class=\"hljs-string\">\"Implement health endpoint\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php language-bash\"><span class=\"hljs-comment\"># Branching and integration<\/span>\ngit checkout -b feature\/health-endpoint\ngit push -u origin feature\/health-endpoint\n\ngit checkout main\ngit pull origin main\ngit merge feature\/health-endpoint\n<span class=\"hljs-comment\"># Alternative integration style<\/span>\n<span class=\"hljs-comment\"># git rebase main<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php language-bash\"><span class=\"hljs-comment\"># Stash and conflict handling<\/span>\ngit stash\ngit stash <span class=\"hljs-keyword\">list<\/span>\ngit stash apply stash@{<span class=\"hljs-number\">0<\/span>}\ngit stash drop stash@{<span class=\"hljs-number\">0<\/span>}\n\n<span class=\"hljs-comment\"># Undo and recovery patterns<\/span>\ngit restore --staged FILE_NAME\ngit restore FILE_NAME\ngit revert COMMIT_SHA<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Feature branch workflow from local work to merge<\/h2>\n\n\n\n<pre class=\"mermaid\">\nflowchart LR\n    A[Clone repository] --> B[Create feature branch]\n    B --> C[Commit local changes]\n    C --> D[Push branch to remote]\n    D --> E[Open pull or merge request]\n    E --> F[Review and CI checks]\n    F --> G{Approved}\n    G -- No --> C\n    G -- Yes --> H[Merge into main]\n    H --> I[Delete feature branch]\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Git, SVN, GitHub, and GitLab comparisons<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Git vs SVN<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Aspect<\/th><th>Git<\/th><th>SVN<\/th><\/tr><\/thead><tbody><tr><td>Model<\/td><td>Distributed version control<\/td><td>Centralized version control<\/td><\/tr><tr><td>Local commits<\/td><td>Yes<\/td><td>No (commit to central server)<\/td><\/tr><tr><td>Branching<\/td><td>Lightweight and commonly used<\/td><td>Supported, often treated as heavier workflow<\/td><\/tr><tr><td>Offline work<\/td><td>Strong (most operations local)<\/td><td>Limited for commit\/history operations<\/td><\/tr><tr><td>Typical modern ecosystem<\/td><td>Strong integration with PR\/MR workflows and CI\/CD platforms<\/td><td>Still used in some legacy\/centralized environments<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">GitHub vs GitLab<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Aspect<\/th><th>GitHub<\/th><th>GitLab<\/th><\/tr><\/thead><tbody><tr><td>Primary role<\/td><td>Git hosting and collaboration platform<\/td><td>Git hosting plus integrated DevOps platform<\/td><\/tr><tr><td>Code review unit<\/td><td>Pull request<\/td><td>Merge request<\/td><\/tr><tr><td>Built-in CI\/CD<\/td><td>GitHub Actions<\/td><td>GitLab CI\/CD<\/td><\/tr><tr><td>Deployment model<\/td><td>Cloud and enterprise\/self-hosted offerings<\/td><td>GitLab.com and self-managed offerings<\/td><\/tr><tr><td>Permissions and governance<\/td><td>Repository and organization controls<\/td><td>Project\/group controls with role-based access<\/td><\/tr><tr><td>Common interview framing<\/td><td>Open-source collaboration and ecosystem<\/td><td>Single-platform SDLC and integrated pipelines<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Command intent comparison: status, diff, and log<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Command<\/th><th>What it shows<\/th><th>Typical interview explanation<\/th><\/tr><\/thead><tbody><tr><td><code>git status<\/code><\/td><td>Current branch, staged and unstaged changes<\/td><td>&#8220;What is the repo state right now?&#8221;<\/td><\/tr><tr><td><code>git diff<\/code><\/td><td>Line-level content differences<\/td><td>&#8220;What exactly changed in files?&#8221;<\/td><\/tr><tr><td><code>git log<\/code><\/td><td>Commit history<\/td><td>&#8220;How has the project evolved over time?&#8221;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Advanced topics often asked<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Git objects:<\/strong> blob (file content), tree (directory snapshot), commit (history node), tag (named reference).<\/li><li><strong><code>git ls-tree<\/code>:<\/strong> Lists contents of a tree object (commonly used for object-level inspection).<\/li><li><strong>Hooks:<\/strong> Script entry points such as pre-commit, pre-push, and server-side hooks for policy enforcement.<\/li><li><strong>Merge vs rebase:<\/strong> Merge preserves branch topology; rebase rewrites commit base for a linear history.<\/li><li><strong>SubGit:<\/strong> Commonly referenced as a bridge\/migration tool between SVN and Git repositories.<\/li><li><strong>Atlassian Stash:<\/strong> Historical product name; now commonly known as Bitbucket Server\/Data Center.<\/li><\/ul>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php language-bash\"><span class=\"hljs-comment\"># Object and tree inspection examples<\/span>\ngit cat-file -p HEAD\ngit ls-tree HEAD\n\n<span class=\"hljs-comment\"># Check whether a branch is already merged<\/span>\ngit branch --merged main\n\n<span class=\"hljs-comment\"># Delete local and remote branch<\/span>\ngit branch -d feature\/old-work\ngit push origin --delete feature\/old-work<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting checklist for Git, GitHub, and GitLab<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Verify branch, staged state, and pending changes before pull\/push.<\/li><li>Confirm remote URLs and expected upstream tracking branch.<\/li><li>Check authentication mode (SSH vs HTTPS) and token\/key validity.<\/li><li>Inspect divergence before force operations; prefer revert over history rewrite on shared branches.<\/li><li>For GitLab administration tasks such as backups, validate commands against your exact edition and deployment method.<\/li><\/ul>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php language-bash\"><span class=\"hljs-comment\"># Quick diagnostics<\/span>\ngit status\ngit branch -vv\ngit remote -v\ngit config --<span class=\"hljs-keyword\">list<\/span> --show-origin\n\n<span class=\"hljs-comment\"># Connectivity checks<\/span>\nssh -T git@github.com\nssh -T git@gitlab.com\n\n<span class=\"hljs-comment\"># Example often used on Omnibus-based GitLab installations<\/span>\n<span class=\"hljs-comment\"># gitlab-backup create<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">The original post also included a YouTube embed that currently appears without a specific video ID. The preserved related link is: <a href=\"https:\/\/www.youtube.com\/watch?v=ZCfrNvu6nMc\" target=\"_blank\" rel=\"noreferrer noopener\">steps in this video<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common pitfalls in interviews<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Confusing <code>git fetch<\/code>, <code>git pull<\/code>, and <code>git push<\/code>.<\/li><li>Using \u201cGitHub\u201d and \u201cGit\u201d as if they are the same thing.<\/li><li>Explaining merge and rebase without discussing history implications.<\/li><li>Using destructive commands (<code>reset --hard<\/code>, force push) without safety context.<\/li><li>Giving definitions without demonstrating command-level understanding.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A practical interview-prep guide covering core Git concepts, essential commands, and common GitHub\/GitLab questions. Includes workflow diagrams, comparisons, and troubleshooting checklists.<\/p>\n","protected":false},"author":1,"featured_media":3397,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[52],"tags":[160,771,1550,405,1548,1551,404,1549,1552,766,507,1553,482,637],"class_list":["post-366","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-interview-questions-answers","tag-git","tag-git-interview","tag-git-interview-questions","tag-github","tag-github-interview","tag-github-interview-questions","tag-gitlab","tag-gitlab-interview","tag-gitlab-interview-questions","tag-interview","tag-list","tag-most-asked","tag-questions","tag-top"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=366"}],"version-history":[{"count":4,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/366\/revisions"}],"predecessor-version":[{"id":79243,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/366\/revisions\/79243"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3397"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}