skip to content

Version Control & Hosting

Git itself plus the platforms built around it — GitHub, GitLab, Bitbucket — where repositories, code review, CI, packages and cloud dev environments live. Interviewers use this area constantly because every job involves a branching model, a review process, and a pipeline attached to a push.

on this pageshow

explore

questions

419 · 8 sections

In Git, what does creating a branch with git branch feature actually do?

level: juniorimportance: must knowfreq 82%
basics
~20 s

It writes one new ref holding the hash of the commit you branched from. No files are copied and no history is duplicated, which is why branching is instant in a repository of any size.

open as a page

In Git, what do the <<<<<<<, =======, and >>>>>>> markers in a conflicted file mean?

level: juniorimportance: must knowfreq 85%
basics
~20 s

Git writes both versions of a region it could not merge into the file. Text between <<<<<<< and ======= is the side you are on; text between ======= and >>>>>>> is the incoming side. You edit the file to the final content, delete the markers, and stage it.

open as a page

In Git, what is a fast-forward merge and when can Git perform one?

level: juniorimportance: must knowfreq 80%
basics
~20 s

A fast-forward merge happens when the current branch's commit is already an ancestor of the commit being merged. Git records no merge commit; it simply moves the branch pointer forward and updates the index and working tree.

open as a page

In Git, what is a three-way merge and which three commits does it use?

level: juniorimportance: must knowfreq 68%
basics
~20 s

A three-way merge combines two branch tips using their best common ancestor, the merge base, as a reference point. Comparing each tip against that base tells Git which side changed what, so it can combine changes instead of guessing.

open as a page

In Git, how do the --system, --global and --local config scopes differ, and which one wins?

level: juniorimportance: must knowfreq 70%
basics
~10 s

They name three config files: machine-wide, per-user, and per-repository. Git reads them in that order and the narrower scope wins, so a repository's .git/config overrides your home-directory settings, which override the system file.

open as a page

With Git LFS, what does a commit actually store for a tracked 300 MB PSD file, and where do the real bytes live?

level: juniorimportance: must knowfreq 55%
basics
~20 s

A Git LFS commit stores a small text pointer holding a spec version, the file's SHA-256 oid and its size; the real bytes sit in the local LFS cache and on the LFS server, swapped in at checkout.

open as a page

With Git LFS, how do you stop a CI job that clones the repository from downloading binaries no build step opens?

level: middleimportance: must knowfreq 44%
basics
~20 s

Set GIT_LFS_SKIP_SMUDGE=1 before cloning so checkout leaves pointer files instead of downloading content, then run git lfs pull with --include for only the paths the build reads. A shallow clone does not reduce LFS downloads.

open as a page

With Git LFS, why does running `git lfs track "*.psd"` after a year of committing PSDs straight into Git leave clones just as large?

level: middleimportance: must knowfreq 38%
basics
~20 s

Tracking only changes how content is cleaned from now on; every PSD committed during that year is still a full blob reachable from history. Shrinking clones needs git lfs migrate import over all refs, which rewrites history.

open as a page

With Git LFS, how do git lfs fetch, git lfs checkout and git lfs pull differ?

level: juniorimportance: should knowfreq 36%
basics
~20 s

git lfs fetch downloads objects into the local LFS store without touching the working copy; git lfs checkout writes content from that store over pointer files without downloading; git lfs pull does both, like fetch followed by checkout.

open as a page

With Git LFS, what do `git lfs install` and `git lfs track "*.psd"` each set up, and what does the resulting .gitattributes line mean?

level: juniorimportance: should knowfreq 42%
basics
~20 s

git lfs install configures the lfs clean, smudge and process filters (globally by default) and installs Git LFS's hooks; git lfs track writes a filter=lfs diff=lfs merge=lfs -text line into .gitattributes, which must be committed.

open as a page

What is GitHub Actions, and where in a repository must a workflow file live to be run?

level: juniorimportance: must knowfreq 72%
basics
~10 s

GitHub Actions is GitHub's built-in automation and CI/CD system. A workflow is a YAML file in the repository's .github/workflows directory that declares the events triggering it and the jobs to run when one occurs.

open as a page

In GitHub, what happens when you push straight to main if a rule requires a pull request?

level: juniorimportance: must knowfreq 68%
basics
~20 s

GitHub's server refuses the push. The remote rejects the ref update with a protected-branch error, nothing lands on main, and your local commits are untouched — you push a topic branch and open a pull request instead.

open as a page

On a GitHub pull request, what is the difference between Approve, Request changes, and Comment?

level: juniorimportance: must knowfreq 75%
basics
~20 s

Approve endorses the pull request and counts toward any required approvals. Request changes records a blocking objection that stays until the reviewer approves or the review is dismissed. Comment leaves feedback with no verdict either way.

open as a page

In GitHub, what is a Dependabot alert and where does its data come from?

level: juniorimportance: must knowfreq 60%
basics
~20 s

A Dependabot alert is GitHub telling you that a package your repository depends on has a known vulnerability. It comes from matching the repository's dependency graph, built from committed manifests and lockfiles, against the GitHub Advisory Database.

open as a page

In GitHub, how do you make a merged pull request close an issue automatically?

level: juniorimportance: must knowfreq 72%
basics
~20 s

Put a closing keyword and the issue number, such as "Fixes #123", in the pull request description or in a commit message. When that pull request merges into the repository's default branch, GitHub closes the linked issue.

open as a page

In GitLab, where does a project's pipeline configuration come from, and what runs when the repository has no .gitlab-ci.yml?

level: juniorimportance: must knowfreq 46%
basics
~20 s

GitLab reads .gitlab-ci.yml from the repository root unless the project's CI/CD configuration file setting names another path, another project's file or a .yml URL. With no file, only Auto DevOps can run, if enabled and it finds a Dockerfile or buildpack.

open as a page

In GitLab, when a CI/CD job pushes an image to its project's container registry, which predefined variables supply the address and the credentials?

level: juniorimportance: must knowfreq 50%
basics
~10 s

CI_REGISTRY is the registry host, CI_REGISTRY_IMAGE is the project's image path under it, and CI_REGISTRY_USER with CI_REGISTRY_PASSWORD log the job in; that password equals CI_JOB_TOKEN and is valid only while the job runs.

open as a page

On GitLab.com, where does an untagged CI job run by default, and what is left of its machine when the next job starts?

level: juniorimportance: must knowfreq 44%
basics
~20 s

On GitLab.com an untagged job runs on the GitLab-hosted small Linux x86-64 runner, in a newly provisioned VM dedicated to that job and deleted when it ends, so nothing on that machine reaches the next job.

open as a page

In a GitLab merge request, what does the security scan report show, and why is a vulnerability already on main missing from it?

level: juniorimportance: must knowfreq 46%
basics
~20 s

It shows what merging would change: findings the source branch adds and findings it fixes, compared against the target branch's security reports. A vulnerability present on both branches is unchanged by the merge, so the report leaves it out.

open as a page

In GitLab, how do GitLab.com, Self-Managed and Dedicated differ, and which fits code that must stay in your own data centre?

level: juniorimportance: must knowfreq 44%
basics
~20 s

GitLab.com is GitLab's shared multi-tenant SaaS, GitLab Dedicated is a single-tenant instance GitLab hosts and runs for you, and GitLab Self-Managed is the same product you install and operate. Only Self-Managed can sit in your own data centre.

open as a page

In Bitbucket Pipelines, what does each step run in, and why is a file built in one step missing in the next?

level: juniorimportance: must knowfreq 40%
basics
~20 s

Each Bitbucket Pipelines step starts a separate Docker container from its image with a fresh clone, so nothing on disk survives the step. Files a later step needs must be declared as artifacts; caches only restore downloaded dependencies.

open as a page

In Bitbucket Pipelines, how do you make the production deployment step wait for a person, and what actually limits who can run it?

level: middleimportance: must knowfreq 32%
basics
~20 s

Give the Bitbucket Pipelines step deployment: production and trigger: manual, so the pipeline pauses until someone promotes it. The pause alone lets anyone with write access deploy; on Premium, deployment permissions restrict each environment to admins or named users and groups.

open as a page

In Bitbucket Cloud, why can a developer merge a pull request with one approval when main's merge check requires two?

level: middleimportance: must knowfreq 34%
basics
~20 s

Bitbucket Cloud merge checks only warn unless the workspace is on Premium and the restriction selects Prevent a merge with unresolved merge checks. Without that, the merge checklist shows the missing approval but anyone with merge access can still merge.

open as a page

In Bitbucket Cloud linked to Jira, why might a commit message like ACME-142 #resolve leave the Jira work item unchanged?

level: middleimportance: must knowfreq 30%
basics
~20 s

A Bitbucket Cloud smart commit runs as the Jira user whose email matches the commit's author email. A mismatched email, missing permission, required transition fields, a malformed key or disabled smart commits stops it; the commit still lands.

open as a page

In Bitbucket Cloud, how do workspaces, projects and repositories relate, and where can access to a repository be granted?

level: juniorimportance: should knowfreq 28%
basics
~20 s

A Bitbucket Cloud workspace owns the repositories, members and user groups; projects group repositories inside it. Access is granted at three levels: workspace user groups, project permissions covering every repository in the project, and permissions on one repository.

open as a page

With the GitHub CLI, what does gh api handle for you that a hand-written curl call to the GitHub API does not?

level: juniorimportance: must knowfreq 45%
basics
~20 s

gh api reuses gh's own credentials, resolves the host and API prefix, fills {owner} and {repo} from the current repository, builds JSON bodies, follows pages, filters with built-in jq and exits non-zero when the API returns an error.

open as a page

With the GitHub CLI, how do you authenticate gh on your own laptop compared with inside a CI job?

level: juniorimportance: must knowfreq 48%
basics
~20 s

On a laptop, gh auth login runs a browser flow with a one-time code and keeps the token in the system credential store. In CI, set GH_TOKEN in the job's environment; gh prefers it to any stored login and never prompts.

open as a page

With the GitHub CLI, what does `gh pr checkout 482` do in your local clone, including when the pull request comes from a fork?

level: juniorimportance: must knowfreq 52%
basics
~20 s

gh pr checkout fetches the pull request's head and checks it out as a local branch named after the head branch, set up to track it; for a fork with no remote it fetches refs/pull/482/head from the base repository instead.

open as a page

With the GitHub CLI's gh api, how do -f/--raw-field and -F/--field differ, and when does adding them change the HTTP method?

level: middleimportance: must knowfreq 36%
basics
~20 s

-f always sends a string; -F converts true, false, null and integers to JSON types, fills {owner}/{repo}/{branch} and reads @file. Adding either switches gh api from GET to POST unless --method is given; --method GET sends them as a query string.

open as a page

With the GitHub CLI, how do you find out from the terminal why last night's scheduled workflow run failed, and rerun only what broke?

level: middleimportance: must knowfreq 44%
basics
~20 s

Find the run with gh run list filtered by workflow, event and status, read only the failing steps with gh run view <id> --log-failed, then gh run rerun <id> --failed and follow it with gh run watch <id> --exit-status.

open as a page

In GitHub Codespaces, where can a repository's devcontainer.json live, and what does a codespace use when there is none?

level: juniorimportance: must knowfreq 38%
basics
~10 s

Codespaces reads .devcontainer/devcontainer.json or a root-level .devcontainer.json, plus alternatives at .devcontainer/NAME/devcontainer.json chosen at creation. With no configuration, it uses a default Linux image with common runtimes and tools.

open as a page

In GitHub Codespaces, why does a codespace stop on its own, and what does it still cost once stopped?

level: juniorimportance: must knowfreq 42%
basics
~20 s

A codespace stops after an idle timeout: 30 minutes by default, settable from 5 to 240. Once stopped it no longer bills compute but keeps billing storage until deleted, which happens automatically after the retention period, 30 days by default.

open as a page

In a GitHub Codespaces devcontainer.json, in what order do the lifecycle commands run, and which should install the project's dependencies?

level: middleimportance: must knowfreq 33%
basics
~10 s

onCreateCommand, updateContentCommand and postCreateCommand finish setup once; postStartCommand runs at every start and postAttachCommand at every attach. Source-dependent installs belong in updateContentCommand, which the editor waits for by default.

open as a page

In a GitHub Codespaces devcontainer.json, which properties give new contributors the team's extensions, a big enough machine and a prompt for their API key?

level: middleimportance: should knowfreq 16%
basics
~10 s

customizations.vscode sets extensions and editor settings, hostRequirements hides machine types below a minimum, and a top-level secrets object prompts creators for recommended personal secrets; customizations.codespaces adds openFiles and extra repository permissions.

open as a page

In a GitHub Codespaces devcontainer.json, what are dev container features, and how do they differ from installing tools in a lifecycle command?

level: middleimportance: should knowfreq 30%
basics
~20 s

Features are versioned, shareable install units referenced by ID in the features object. Their scripts run as root during the image build, each as a cached layer, whereas lifecycle commands run later inside the started container.

open as a page

In GitHub Packages, what visibility can a package have, and what changes once you make a container image public?

level: juniorimportance: must knowfreq 42%
basics
~10 s

A GitHub Packages package is private, internal or public, and an account-scoped package starts private. Making it public cannot be undone, and a public container image can then be pulled anonymously by anyone.

open as a page

In GitHub Packages, what is the Container registry at ghcr.io, and how do you log the Docker client in to push an image there?

level: juniorimportance: must knowfreq 48%
basics
~20 s

ghcr.io is the GitHub Packages registry for Docker and OCI images, scoped to a user or organisation. Log in with docker login ghcr.io using a classic personal access token with write:packages, or GITHUB_TOKEN with packages: write inside a workflow.

open as a page

In GitHub Packages, how do granular package permissions differ from repository-scoped ones, and when does a package inherit its linked repository's access?

level: middleimportance: must knowfreq 34%
basics
~20 s

Container, npm, NuGet and RubyGems packages belong to an account and can carry their own Read, Write and Admin roles; Maven and Gradle packages always follow their repository. A linked package inherits repository access until you remove that inheritance.

open as a page

In GitHub Packages, how does Maven find the token for maven.pkg.github.com, and why must the repository id match a settings.xml server id?

level: middleimportance: should knowfreq 24%
basics
~10 s

Maven sends credentials only for a repository whose id matches a server id in ~/.m2/settings.xml; that server holds the GitHub username and a classic token, and the repository URL is https://maven.pkg.github.com/OWNER/REPOSITORY.

open as a page