Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Git, GitHub, and GitLab Interview Questions: Practical Answers and Command Guide

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.

Originally published on 2014-08-18; fully revised and updated.

Original post: Git Interview Questions and Answer Part – 6.

Interview questions on Git GitHub and GitLab

What interviewers usually test

Most Git interview rounds check whether you can explain concepts and apply them with commands. Expect a mix of fundamentals, branch strategy, collaboration flow, and incident recovery.

  • Core concepts: repository, commit, staging area, HEAD, branch, merge, rebase
  • Daily command fluency: status, diff, add, commit, log, pull, push
  • Collaboration: pull/merge requests, conflict resolution, branch cleanup
  • Platform awareness: GitHub vs GitLab and CI/CD integration
  • Troubleshooting: auth failures, diverged branches, bad commits

Core Git interview questions and concise answers

  • What is Git? Git is a distributed version control system that tracks file changes and enables collaborative development.
  • What is a repository? A repository (repo) stores project files plus history (commits, branches, tags).
  • What is the staging area (index)? It is an intermediate area where you select exactly what goes into the next commit.
  • What does git commit -m do? It records staged changes and attaches the provided commit message.
  • What does git push do? It sends local commits to a remote repository reference (for example, origin/main).
  • What is git clone used for? It copies an existing remote repository locally, including history and refs.
  • What is the difference between git remote and git clone? git clone creates a local copy; git remote manages remote names and URLs in an existing local repo.
  • What is HEAD? HEAD is a reference to your current checked-out commit (typically the tip of the active branch).
  • What is a bare repository? A repository without a working tree, commonly used as a central/shared remote.
  • What is git stash? It temporarily shelves uncommitted changes so you can switch context safely.
  • What does git stash drop do? It removes a stored stash entry after you no longer need it.
  • What does a commit object contain? A snapshot reference (tree), parent commit reference(s), author/committer metadata, timestamps, and message.
  • What language is Git written in? Git core is primarily written in C, with supporting tooling historically including shell and Perl scripts.
  • How is Git different from SVN? Git is distributed and local-first; SVN is centralized with a single canonical repository workflow.

Essential commands you should be able to explain

Interviewers often ask you to narrate what each command does and when you would choose it.

# Initialize or copy a repository
git init
git clone https://example.com/team/app.git

# Inspect local state
git status
git diff
git log --oneline --graph --decorate -n 10

# Stage and commit
git add .
git commit -m "Implement health endpoint"Code language: PHP (php)
# Branching and integration
git checkout -b feature/health-endpoint
git push -u origin feature/health-endpoint

git checkout main
git pull origin main
git merge feature/health-endpoint
# Alternative integration style
# git rebase mainCode language: PHP (php)
# Stash and conflict handling
git stash
git stash list
git stash apply stash@{0}
git stash drop stash@{0}

# Undo and recovery patterns
git restore --staged FILE_NAME
git restore FILE_NAME
git revert COMMIT_SHACode language: PHP (php)

Feature branch workflow from local work to merge

flowchart LR
    A[Clone repository] --> B[Create feature branch]
    B --> C[Commit local changes]
    C --> D[Push branch to remote]
    D --> E[Open pull or merge request]
    E --> F[Review and CI checks]
    F --> G{Approved}
    G -- No --> C
    G -- Yes --> H[Merge into main]
    H --> I[Delete feature branch]

Git, SVN, GitHub, and GitLab comparisons

Git vs SVN

AspectGitSVN
ModelDistributed version controlCentralized version control
Local commitsYesNo (commit to central server)
BranchingLightweight and commonly usedSupported, often treated as heavier workflow
Offline workStrong (most operations local)Limited for commit/history operations
Typical modern ecosystemStrong integration with PR/MR workflows and CI/CD platformsStill used in some legacy/centralized environments

GitHub vs GitLab

AspectGitHubGitLab
Primary roleGit hosting and collaboration platformGit hosting plus integrated DevOps platform
Code review unitPull requestMerge request
Built-in CI/CDGitHub ActionsGitLab CI/CD
Deployment modelCloud and enterprise/self-hosted offeringsGitLab.com and self-managed offerings
Permissions and governanceRepository and organization controlsProject/group controls with role-based access
Common interview framingOpen-source collaboration and ecosystemSingle-platform SDLC and integrated pipelines

Command intent comparison: status, diff, and log

CommandWhat it showsTypical interview explanation
git statusCurrent branch, staged and unstaged changes“What is the repo state right now?”
git diffLine-level content differences“What exactly changed in files?”
git logCommit history“How has the project evolved over time?”

Advanced topics often asked

  • Git objects: blob (file content), tree (directory snapshot), commit (history node), tag (named reference).
  • git ls-tree: Lists contents of a tree object (commonly used for object-level inspection).
  • Hooks: Script entry points such as pre-commit, pre-push, and server-side hooks for policy enforcement.
  • Merge vs rebase: Merge preserves branch topology; rebase rewrites commit base for a linear history.
  • SubGit: Commonly referenced as a bridge/migration tool between SVN and Git repositories.
  • Atlassian Stash: Historical product name; now commonly known as Bitbucket Server/Data Center.
# Object and tree inspection examples
git cat-file -p HEAD
git ls-tree HEAD

# Check whether a branch is already merged
git branch --merged main

# Delete local and remote branch
git branch -d feature/old-work
git push origin --delete feature/old-workCode language: PHP (php)

Troubleshooting checklist for Git, GitHub, and GitLab

  • Verify branch, staged state, and pending changes before pull/push.
  • Confirm remote URLs and expected upstream tracking branch.
  • Check authentication mode (SSH vs HTTPS) and token/key validity.
  • Inspect divergence before force operations; prefer revert over history rewrite on shared branches.
  • For GitLab administration tasks such as backups, validate commands against your exact edition and deployment method.
# Quick diagnostics
git status
git branch -vv
git remote -v
git config --list --show-origin

# Connectivity checks
ssh -T git@github.com
ssh -T git@gitlab.com

# Example often used on Omnibus-based GitLab installations
# gitlab-backup createCode language: PHP (php)

The original post also included a YouTube embed that currently appears without a specific video ID. The preserved related link is: steps in this video.

Common pitfalls in interviews

  • Confusing git fetch, git pull, and git push.
  • Using “GitHub” and “Git” as if they are the same thing.
  • Explaining merge and rebase without discussing history implications.
  • Using destructive commands (reset --hard, force push) without safety context.
  • Giving definitions without demonstrating command-level understanding.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

TFS Interview Questions and Answers: Practical DevOps Guide

A structured, interview-focused guide to Team Foundation Server (TFS), including TFVC vs Git, build and reporting topics, and practical command examples. Use it to prepare concise, technically strong answers for common TFS interview scenarios.

Read More

Chef Interview Q&A (Part 2): Resources, Run-Lists, Bootstrap, and Test Kitchen

A practical rewrite of classic Chef interview questions, focused on how Chef resources converge, how run-lists drive node configuration, and how to test cookbooks safely. Includes command examples, workflow diagrams, and comparison tables.

Read More

Chef Interview Questions, Explained: Resources, Run-Lists, Bootstrapping, and Test Kitchen

This updated guide converts classic Chef interview Q&A into a practical reference for real infrastructure work. It covers core concepts, execution order, bootstrap flow, key knife commands, and Test Kitchen testing patterns.

Read More

SVN Interview Questions and Answers: Trunk, Branch, Tag, Update, Commit, Patch, Backup, and Authentication

A practical, interview-focused guide to Subversion (SVN) concepts and commands. Learn how to explain trunk/branch/tag, update vs commit, conflict handling, patching, backup/restore, and auth setup with confidence.

Read More

Jenkins Interview Questions, Answered: CI, APIs, Installation, Backups, and Essential Plugins

This revised guide turns common Jenkins interview prompts into practical answers you can explain with confidence. It covers CI fundamentals, API usage, setup on Ubuntu and RHEL-like systems, backup strategy, and key plugins.

Read More

Build and Release Engineer Interview Guide: Questions, Answer Frameworks, and Tool Comparisons

A practical, updated interview guide for Build, Release, and Configuration Engineering roles. Use it to prepare better answers or run more consistent technical interviews.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x