1. You want to work on two branches simultaneously from the same repo without stashing. What feature helps?
`git worktree add ../path <branch>` creates another working tree tied to the same `.git` data, enabling parallel checkouts.
Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Git & Version Control · Question Set
Remotes, Sync & Tags — Collaboration Deep Dive interview questions for placements and exams.
Questions
14
Included in this set
Subject
Git & Version Control
Explore more sets
Difficulty
Mixed
Level of this set
Go through each question and its explanation. Use this set as a focused practice pack for Git & Version Control.
`git worktree add ../path <branch>` creates another working tree tied to the same `.git` data, enabling parallel checkouts.
For complete preparation, combine this set with full subject-wise practice for Git & Version Control. You can also explore other subjects and sets from the links below.
A remote is a named reference to another copy of the repository, typically hosted on a server. 'origin' is the default name Git assigns when you clone, pointing back to the source repository. It lets you fetch, pull, and push changes for collaboration.
`git remote set-url` updates the fetch/push URLs for a named remote.
An upstream branch is the remote branch your local branch integrates with by default for pull/push. Set it via `git branch --set-upstream-to=origin/main` or on first push using `git push -u origin <branch>`.
`pull` first fetches remote tracking changes then integrates them, while `fetch` only updates remote-tracking refs.
`--prune` deletes local stale remote-tracking branches (e.g., origin/feature-x) removed from the remote.
`push.default=simple` pushes the current branch to its upstream of the same name and rejects if names differ. `git push --all` pushes all local branches that have matching names to the remote.
`--rebase` linearizes history by replaying local commits over the updated upstream.
`--tags` tells Git to send all tag refs to the target remote.
`--depth 1` creates a shallow clone with truncated history for speed and reduced size.
In fork-based workflows, `origin` is your fork; `upstream` is the source project. You fetch from `upstream` to stay current, rebase your feature branch, push to `origin`, and open a PR back to `upstream`.
A submodule embeds another repo at a specific commit. After cloning, run `git submodule init` then `git submodule update` (or `git submodule update --init --recursive`) to fetch and checkout submodule contents.
Pushing an empty ref (`:<name>`) deletes the remote branch. Modern alternative: `git push origin --delete feature/login`.
Lightweight tags are simple pointers to a commit. Annotated tags (`git tag -a`) store metadata (tagger, date, message, GPG sig). Use annotated tags for releases; lightweight tags for local/bookmark usage.