CS FundamentalsModerateAccenture · Infosys · Git interview
You have 2 local commits on main and the remote main has 3 new commits. What does git pull --rebase do?
- A. Creates a merge commit joining the two histories
- B. Discards your 2 local commits and takes the remote's
- C. Fetches and then replays your 2 commits on top of the 3 remote commits, giving them new hashes and a linear history
- D. Pushes your 2 commits first and then pulls
Correct answer: C. Fetches and then replays your 2 commits on top of the 3 remote commits, giving them new hashes and a linear history
pull --rebase = fetch + rebase onto the updated upstream. Your commits are re-created (new hashes) after the remote ones, with no merge commit. Since they were unpublished, rewriting them is safe.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- You staged changes to app.py with git add but now want them out of the next commit while keeping the edits in your working tree. Which…
- During git rebase main, a conflict stops the rebase. You edit the file to resolve it. What should you do next?
- After git fetch, git status says: "Your branch is behind 'origin/main' by 3 commits, and can be fast-forwarded." Which statement is correct?
- A repository has untracked files temp.txt and out/build.log; .log is in .gitignore. What does git clean -fd remove?
- Assertion (A): You should not rebase commits that others have already based work on. Reason (R): Rebasing creates new commits with new…
- You run git branch -d experiment and Git refuses: 'the branch is not fully merged'. You force it with git branch -D. Which statement is…