Git & GitHub Interview

Remotes, Fetch, Pull, Push, Merge, Conflicts, Rebase & Stash

Git & GitHub interview questions 26-50: Remotes, Fetch, Pull, Push, Merge, Conflicts, Rebase & Stash.

25 Questions Filter by level

Interview questions

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

25 Results
26
JuniorBeginner

How do you list branches in Git?

git branch lists local branches, with the currently checked-out branch marked. Options can also show remote-tracking branches or both local and remote-tracking branches.

27
JuniorBeginner

How do you rename a Git branch?

A local branch can be renamed with git branch -m. If the renamed branch has already been published, the remote branch and upstream configuration may also need to be updated.

28
JuniorBeginner

How do you delete a Git branch?

git branch -d deletes a local branch when Git considers the deletion safe, such as when its work has been merged appropriately. The -D option forces local deletion even when Git detects unmerged work.

29
JuniorBeginner

What is a remote in Git?

A remote is a named reference to another repository location, commonly hosted on GitHub or another Git server. It stores connection information that Git uses for operations such as fetch and push.

30
JuniorBeginner

What does origin mean in Git?

origin is simply the conventional default name Git gives to the source remote when a repository is cloned. It is not a special Git keyword that always means GitHub or the main repository.

31
JuniorBeginner

How do you add, change, or remove a Git remote?

git remote add creates a named remote. git remote set-url changes its URL, and git remote remove deletes the remote configuration from the local repository.

32
JuniorBeginner

What does git fetch do?

git fetch downloads new commits, branches, tags, and related references from a remote without automatically merging those changes into the currently checked-out branch.

33
JuniorBeginner

What does git pull do?

git pull retrieves changes from a remote and then integrates them into the current branch. By default this commonly means fetch followed by merge, although configuration or command options can make pull use rebase instead.

34
JuniorBeginner

What is the difference between git fetch and git pull?

git fetch downloads remote history and updates remote-tracking references without changing the current branch's working history. git pull fetches and then attempts to integrate the fetched changes into the current branch.

35
JuniorBeginner

What does git push do?

git push sends local references and the commits needed to update a remote repository. A common use is publishing local branch commits to GitHub.

36
JuniorBeginner

What is an upstream branch in Git?

An upstream branch is the branch that a local branch is configured to track, commonly a remote-tracking branch such as origin/main or origin/feature/search.

37
JuniorBeginner

What is a remote-tracking branch?

A remote-tracking branch is a local reference that records Git's last known state of a branch in a remote repository. Names such as origin/main and origin/develop are common examples.

38
JuniorBeginner

What is a merge in Git?

A merge combines development histories. Git finds the relevant common history and incorporates changes from another branch into the current branch.

39
JuniorBeginner

What is a fast-forward merge?

A fast-forward merge is possible when the current branch has no new commits after the point where the other branch diverged. Git can simply move the current branch reference forward to the newer commit.

40
JuniorBeginner

What is a three-way merge?

A three-way merge combines two branch tips using their common ancestor as a third reference point. Git compares how each side changed relative to that ancestor and creates a merged result.

41
Mid-LevelIntermediate

What is a merge conflict?

A merge conflict occurs when Git cannot safely determine how competing changes should be combined. A common example is when two branches modify the same lines differently, although conflicts can also involve file deletion, renaming, or other incompatible changes.

42
Mid-LevelIntermediate

How do you resolve a merge conflict?

First inspect git status to identify conflicted files. Open each file, understand both versions, and edit it into the correct final result. Conflict markers such as <<<<<<<, =======, and >>>>>>> must not remain unless they are intentionally part of the file content.

43
Mid-LevelIntermediate

How can you abort a merge?

If a merge is in progress and you decide not to complete it, git merge --abort attempts to restore the pre-merge state.

44
Mid-LevelIntermediate

What is rebase in Git?

Rebase moves or reapplies commits onto a different base commit. A common workflow takes commits from a feature branch and replays them on top of the latest main branch, producing a more linear history.

45
Mid-LevelIntermediate

What is the difference between merge and rebase?

Merge combines histories while preserving their existing branch structure and may create a merge commit. Rebase reapplies commits onto a new base and rewrites those commit identities, often producing a linear history.

46
Mid-LevelIntermediate

What is interactive rebase?

Interactive rebase allows selected commits to be reordered, combined, edited, reworded, or removed while rewriting a portion of history. It is commonly used to clean up local feature-branch commits before they are shared.

47
Mid-LevelIntermediate

How do you continue or abort a rebase after conflicts?

When a rebase stops because of a conflict, resolve the affected files and stage the resolutions. Then run git rebase --continue so Git can continue replaying commits.

48
Mid-LevelIntermediate

What is git stash?

git stash temporarily saves selected working-tree and index changes so you can return to a cleaner working state without creating a normal project commit. It is useful when unfinished work must be set aside briefly to switch branches or handle an urgent task.

49
Mid-LevelIntermediate

What is the difference between git stash apply and git stash pop?

git stash apply reapplies a stash but normally keeps the stash entry in the stash list. git stash pop reapplies it and, when successful, removes that stash entry.

50
Mid-LevelIntermediate

What is the difference between git reset and git revert?

git reset moves a branch reference and can also change the index and working tree depending on the selected mode. It is commonly used to adjust local history or staging, but resetting published history can disrupt collaborators.