Which statement best describes the relationship between commits and branches in Git?

Dive into the Architect Journey – Development Lifecycle and Deployment Exam. Prep with tailored flashcards, explore multiple choice questions with detailed explanations, and enhance your readiness for the test!

Multiple Choice

Which statement best describes the relationship between commits and branches in Git?

Explanation:
In Git, history is built from commits and branches working as references. A branch is a movable pointer to a specific commit, while commits themselves are immutable objects that store the snapshot of changes plus metadata and a link to their parent(s). When you make a new commit, Git creates a new commit object and moves the current branch pointer to that new commit. Because commits are immutable, you don’t modify an existing commit; you create new ones or rewrite history, while the old commit remains unchanged. This setup allows multiple branches to share the same commit and then diverge as they each advance with new commits. Branches exist both locally and remotely; they’re not confined to remote repositories. Commits don’t store branch names; they hold the actual changes, metadata, and pointers to parent commits.

In Git, history is built from commits and branches working as references. A branch is a movable pointer to a specific commit, while commits themselves are immutable objects that store the snapshot of changes plus metadata and a link to their parent(s). When you make a new commit, Git creates a new commit object and moves the current branch pointer to that new commit. Because commits are immutable, you don’t modify an existing commit; you create new ones or rewrite history, while the old commit remains unchanged. This setup allows multiple branches to share the same commit and then diverge as they each advance with new commits. Branches exist both locally and remotely; they’re not confined to remote repositories. Commits don’t store branch names; they hold the actual changes, metadata, and pointers to parent commits.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy