Fatskills
Practice. Master. Repeat.
Study Guide: Comp. Sci and Programming Basics: Version Control - Git Basics (Repository, Commit, Push, Pull, Branch, Merge)
Source: https://www.fatskills.com/civics/chapter/version-control-git-basics-repository-commit-push-pull-branch-merge

Comp. Sci and Programming Basics: Version Control - Git Basics (Repository, Commit, Push, Pull, Branch, Merge)

By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.

⏱️ ~6 min read

Concept Summary

  • A Git repository is a central location where all project files and history are stored.
  • A commit is a snapshot of changes made to the repository at a specific point in time.
  • The push command is used to upload local changes to a remote repository, while the pull command is used to download changes from a remote repository.
  • A branch is a separate line of development in a repository, allowing multiple versions of a project to be worked on simultaneously.
  • The merge command is used to combine changes from different branches into a single branch.

Questions

WHAT (definitional)

  • Q: What is a Git repository?
  • Answer: A Git repository is a central location where all project files and history are stored.
  • Real-world example: A company's codebase is stored in a Git repository, allowing multiple developers to collaborate on the project.
  • Misconception cleared: A Git repository is not just a folder on your computer, but a centralized location that stores all project files and history.
  • Q: What is a commit?
  • Answer: A commit is a snapshot of changes made to the repository at a specific point in time.
  • Real-world example: When you commit your changes, you are creating a new snapshot of your project that includes all the changes you've made since the last commit.
  • Misconception cleared: A commit is not just a save button, but a way to record a specific point in time in the project's history.
  • Q: What is a branch?
  • Answer: A branch is a separate line of development in a repository, allowing multiple versions of a project to be worked on simultaneously.
  • Real-world example: A company might have a main branch for the production version of their software and a separate branch for a new feature that's still in development.
  • Misconception cleared: A branch is not just a copy of the main codebase, but a separate line of development that allows multiple versions of a project to be worked on simultaneously.

WHY (causal reasoning)

  • Q: Why do we need to commit changes?
  • Answer: We need to commit changes to record a specific point in time in the project's history and to allow others to see the changes we've made.
  • Real-world example: If multiple developers are working on the same project, committing changes allows them to see each other's work and avoid conflicts.
  • Misconception cleared: Committing changes is not just a good practice, but a necessary step in collaborative development.
  • Q: Why do we need to use branches?
  • Answer: We need to use branches to allow multiple versions of a project to be worked on simultaneously and to avoid conflicts between different lines of development.
  • Real-world example: A company might have a main branch for the production version of their software and a separate branch for a new feature that's still in development.
  • Misconception cleared: Branches are not just a way to create a copy of the main codebase, but a way to manage multiple lines of development.
  • Q: Why do we need to merge branches?
  • Answer: We need to merge branches to combine changes from different lines of development into a single branch.
  • Real-world example: When a new feature is complete, it needs to be merged into the main branch so that it can be released to production.
  • Misconception cleared: Merging branches is not just a way to combine code, but a way to integrate changes from different lines of development.

HOW (process/application)

  • Q: How do we create a new branch?
  • Answer: We create a new branch by using the git branch command and specifying the name of the new branch.
  • Real-world example: To create a new branch for a new feature, you would use the command git branch feature/new-feature.
  • Misconception cleared: Creating a new branch is not just a matter of copying the main codebase, but a process that involves creating a new reference to the current state of the repository.
  • Q: How do we merge branches?
  • Answer: We merge branches by using the git merge command and specifying the name of the branch to merge.
  • Real-world example: To merge a new feature into the main branch, you would use the command git merge feature/new-feature.
  • Misconception cleared: Merging branches is not just a matter of combining code, but a process that involves resolving conflicts and integrating changes from different lines of development.
  • Q: How do we push changes to a remote repository?
  • Answer: We push changes to a remote repository by using the git push command and specifying the name of the remote repository and the branch to push.
  • Real-world example: To push changes to a remote repository, you would use the command git push origin main.
  • Misconception cleared: Pushing changes to a remote repository is not just a matter of uploading code, but a process that involves updating the remote repository with the latest changes.

CAN (possibility/conditions)

  • Q: Can we commit changes without pushing them to a remote repository?
  • Answer: Yes, we can commit changes without pushing them to a remote repository.
  • Real-world example: You can commit changes locally and then push them to a remote repository later.
  • Misconception cleared: Committing changes does not automatically push them to a remote repository.
  • Q: Can we merge branches without committing changes?
  • Answer: No, we cannot merge branches without committing changes.
  • Real-world example: You need to commit changes before you can merge branches.
  • Misconception cleared: Merging branches requires committed changes.
  • Q: Can we push changes to a remote repository without committing them?
  • Answer: No, we cannot push changes to a remote repository without committing them.
  • Real-world example: You need to commit changes before you can push them to a remote repository.
  • Misconception cleared: Pushing changes to a remote repository requires committed changes.

TRUE/FALSE (misconception testing)

  • Q: A Git repository is just a folder on your computer.
  • Answer: FALSE
  • Real-world example: A Git repository is a centralized location that stores all project files and history.
  • Misconception cleared: A Git repository is not just a folder on your computer, but a centralized location that stores all project files and history.
  • Q: Committing changes automatically pushes them to a remote repository.
  • Answer: FALSE
  • Real-world example: You need to use the git push command to push changes to a remote repository.
  • Misconception cleared: Committing changes does not automatically push them to a remote repository.
  • Q: Merging branches is a one-way process.
  • Answer: FALSE
  • Real-world example: Merging branches can be a two-way process that involves resolving conflicts and integrating changes from different lines of development.
  • Misconception cleared: Merging branches is not a one-way process, but a process that involves resolving conflicts and integrating changes from different lines of development.