Git & GitHub Interview

Security, Team Workflows, Troubleshooting & Senior Git/GitHub Scenarios

Git & GitHub interview questions 126-150: Security, Team Workflows, Troubleshooting & Senior Git/GitHub Scenarios.

25 Questions Filter by level

Interview questions

Open a question for the full answer, code and interview guidance.

25 Results
126
SeniorAdvanced

What is a Git hook?

A Git hook is a script that Git can execute automatically at specific points in a repository workflow, such as before a commit, after a commit, before a push, or during server-side receive operations.

127
SeniorAdvanced

What is the difference between client-side and server-side Git hooks?

Client-side hooks run on a developer's machine during operations such as commit or push. They are useful for fast feedback but cannot be trusted as the only enforcement mechanism because users can omit, change, or bypass local hooks.

128
SeniorAdvanced

What is commit signing and why is it used?

Commit signing adds a cryptographic signature to a commit so a hosting platform or another user can verify that the commit was signed by a key associated with the claimed signer. Git supports signing mechanisms configured by the developer, including supported GPG, SSH, or S/MIME workflows.

129
SeniorAdvanced

How should credentials and secrets be handled in a Git repository?

Passwords, API keys, access tokens, private keys, connection secrets, and similar credentials should not be committed to source control. Use appropriate secret stores, environment variables, local configuration excluded by .gitignore, or deployment-platform secret management.

130
SeniorAdvanced

What should you do if a secret is accidentally pushed to GitHub?

Treat the exposed secret as compromised. Revoke or rotate the credential first so any copied value becomes unusable. Then remove the secret from the current project state and determine whether repository history must be rewritten according to the organization's incident process.

131
SeniorAdvanced

What is secret scanning on GitHub?

Secret scanning detects supported credential patterns in repository content and can alert repository owners or providers when potentially exposed secrets are found. Available capabilities depend on repository and account configuration.

132
SeniorAdvanced

What is Dependabot on GitHub?

Dependabot is a GitHub feature that can help identify vulnerable dependencies and automate dependency update workflows. Depending on configuration, it can generate alerts and propose pull requests that update dependency versions.

133
SeniorAdvanced

What is a merge queue on GitHub?

A merge queue helps repositories integrate pull requests into a busy protected branch while validating them against the latest expected target state. Instead of every approved pull request racing to merge independently, queued changes can be tested in an ordered integration process.

134
SeniorAdvanced

What is a good branching strategy for a small development team?

A small team often benefits from a simple strategy: keep main stable, create short-lived feature or fix branches, open focused pull requests, run automated checks, review changes, and delete merged branches.

135
SeniorAdvanced

What is GitHub Flow?

GitHub Flow is a lightweight branch-based workflow commonly centered on a deployable main branch. Work is performed on a descriptive branch, pushed to GitHub, reviewed through a pull request, validated, merged, and then deployed according to the project's process.

136
SeniorAdvanced

What is Git Flow?

Git Flow is a branching model built around longer-lived branches such as main and develop, with supporting feature, release, and hotfix branches. It was designed for projects with structured release cycles.

137
SeniorAdvanced

What is trunk-based development?

Trunk-based development keeps developers integrating frequently into a single primary branch, often called main or trunk. Feature branches, when used, are normally short-lived and changes are kept small.

138
SeniorAdvanced

What is a hotfix branch?

A hotfix branch is a short-lived branch created to address an urgent production problem. It should contain the smallest safe change needed to correct the issue and should go through appropriate review and testing even when the response is time-sensitive.

139
SeniorAdvanced

How do you handle a production bug when main has already moved ahead?

First identify the exact production version or commit and understand whether the current main branch can safely produce the fix. If production is maintained on a separate release line, create the fix from the appropriate release commit or branch rather than blindly deploying unrelated main changes.

140
SeniorAdvanced

What does git push --force do and why is it risky?

A force push tells the remote to update a branch even when the update is not a normal fast-forward. It can replace published branch history and make commits used by collaborators disappear from the branch reference.

141
SeniorAdvanced

What is the difference between --force and --force-with-lease?

--force overwrites the remote branch reference without checking whether it changed since your last view. --force-with-lease adds a safety check and normally refuses the update if the remote reference no longer matches the value you expected.

142
SeniorAdvanced

How do you troubleshoot a non-fast-forward push rejection?

A non-fast-forward rejection usually means the remote branch contains commits that your local branch does not include, or your local history was rewritten. Start by fetching and inspecting the difference rather than immediately force pushing.

143
SeniorAdvanced

How do you troubleshoot 'repository not found' or authentication errors with GitHub?

First verify the remote URL, repository existence, account access, and whether the repository is private. Then confirm that the selected authentication method is correctly configured and that the credential has the required permissions.

144
SeniorAdvanced

What is the difference between HTTPS and SSH authentication for GitHub?

HTTPS and SSH are two common transport and authentication approaches for GitHub Git operations. HTTPS typically authenticates using supported credentials or credential-manager flows, while SSH uses a public/private key pair configured for the account.

145
SeniorAdvanced

What should you do before deleting a local or remote branch?

Confirm that the branch's required work has been merged, rebased, cherry-picked, tagged, or otherwise preserved. Check the branch commits relative to the target branch and verify that no active pull request or deployment still depends on it.

146
SeniorAdvanced

What does git fetch --prune do?

git fetch --prune fetches updates and removes stale remote-tracking references for branches that no longer exist on the remote. It does not normally delete your local branches.

147
SeniorAdvanced

How can you find which branches contain a particular commit?

git branch --contains can list local branches whose history contains a specified commit. Adding appropriate options can include remote-tracking branches.

148
SeniorAdvanced

How would you clean up a messy feature branch before opening a pull request?

First synchronize your knowledge of the target branch and inspect the feature branch's commits and diff. Remove accidental files, split unrelated work if necessary, and ensure the branch builds and tests successfully.

149
SeniorAdvanced

How would you investigate when a GitHub Actions workflow passes locally but fails in CI?

Compare the CI environment with the local environment systematically. Check operating system, runtime and SDK versions, environment variables, working directory, file-name casing, line endings, dependency versions, network access, permissions, secrets, and commands used by the workflow.

150
SeniorAdvanced

Describe a production-quality Git and GitHub workflow for a .NET development team.

Keep the primary branch protected and deployable. Developers synchronize with the remote, create short-lived branches for focused changes, make clear commits, and push those branches to GitHub. Changes enter the primary branch through pull requests rather than direct unreviewed pushes.